473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

java mysql connection

3
hello all,

i am trying to connect a java application to a mysql database. But when i run the application, i get this error: com.mysql.jdbc.Driver. What am i doing wrong?

this is my code

Class.forName("com.mysql.jdbc.Driver").newInstance ();


con = DriverManager.getConnection("jdbc:mysql://localhost:8080//test","root", "password");
stat = con.createStatement();

korkor
Mar 28 '07 #1
8 5908
sicarie
4,677 Expert Mod 4TB
hello all,

i am trying to connect a java application to a mysql database. But when i run the application, i get this error: com.mysql.jdbc.Driver. What am i doing wrong?

this is my code

Class.forName("com.mysql.jdbc.Driver").newInstance ();


con = DriverManager.getConnection("jdbc:mysql://localhost:8080//test","root", "password");
stat = con.createStatement();

korkor
Did you add it to your classpath, or associate it as a library with the project?
Mar 28 '07 #2
ak1dnar
1,584 Expert 1GB
Hi sicarie,
If i am using a remote web server located at http://www.companyname.com, how can i use his kind of drivers.
Mar 29 '07 #3
korkor
3
Did you add it to your classpath, or associate it as a library with the project?
is this the way to add to the class path?

Class c = Class.forNames("com.mysql.jdbc.Driver");

korkor
Mar 29 '07 #4
sicarie
4,677 Expert Mod 4TB
Hi sicarie,
If i am using a remote web server located at http://www.companyname.com, how can i use his kind of drivers.
ajaxrand-

It's considered bad form to "hijack" some else's thread (ask your question in their thread. Please start your own thread for this question.
Mar 30 '07 #5
sicarie
4,677 Expert Mod 4TB
is this the way to add to the class path?

Class c = Class.forNames("com.mysql.jdbc.Driver");

korkor
No, classpath is dependent on computer - are you on Windows or Linux?
Mar 30 '07 #6
korkor
3
[quote=sicarie]No, classpath is dependent on computer - are you on Windows or Linux?[/QUOTE

im on windows

korkor
Mar 30 '07 #7
ak1dnar
1,584 Expert 1GB
what is the driver you are using in your machine to connect with MySQL ?
Mar 30 '07 #8
sicarie
4,677 Expert Mod 4TB
korkor-

From the Start Menu, go to Settings and click on 'Control Panel'. Then go to the System icon (in classic view, I'm not sure if this is in category view or not), and the 'Advanced' tab from there. In the Advanced tab, click on the Environmental Variables button. This will display your path (it's in the bottom box, you might have to scroll down for it). You only want to add to this (not delete anything that is not there. Highlight the Path and click the edit button, and then add the absolute location of your driver. Make sure this location is separated from the entries before and after it with a semi-colon and no spaces.

For instance, this is mine:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem

and I would change this to:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;C:\Windows\drivers\jdbc\com.mysql.jdbc .Driver.jar;

An easier option (and one that's more portable), is to (depending on your IDE) add it as a library - in NetBeans, you just right-click on Library, add jar, and find the file.
Mar 30 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: apchar | last post by:
I am trying to use php as a kind of servlet to act as a middle man between a java applet and mysql. I know java has jdbc but it's flakey and painful. php access to mysql is much nicer. So I have:...
0
by: Mark | last post by:
Using a Java program, I can connect to the test database in MySQL. The test database is installed using a MySQL utility, and it can be accessed by any user without supplying a password. The...
2
by: WilHob | last post by:
Hello: I can not make connection to MySQL from Java. I set System Variable CLASSPATH to: C:\MySQL\mysql-connector-java-5.0.5\mysql-connector-java-5.0.5-bin.jar ... Then registered Driver:...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
1
by: nickyeng | last post by:
imageValue=null SEVERE:--> com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'Gout_msgtext' cannot be null at...
8
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql with java in eclipse environment. Coding Part: import java.sql.Connection; import java.sql.DriverManager; public class...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
1
by: swethak | last post by:
hi, when i run a java program for to store data and retrive using mysql datatabse i got the following errors.I think in that one of error is due to set the class path.I placed my...
0
by: asti1987 | last post by:
I have a big problem, y need to print a jasper report, but it must to be with jsp. this is my jsp please help me <%@ page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.