• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cant find JDBC driver  RSS feed

 
J Noble
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I am trying to run a simple program that connects to a mysql database and prints out some fields. I am using Eclipse.

THe problem I am having is on the following line of code.
Class.forName("com.mysql.jdbc.Driver");

I get an error:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at mySQLConnect.Connect.main(Connect.java:23)


I have done some research and from what I have found is that I need to alter the class path to pick up the driver.

When I downloaded the .msi I ran it and then the program closed. I have no idea where the files are ???

Can anyone advise on how to locate and import the file so I need to get my program to run?

I have included all the of the source code below.










 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J Noble wrote:
When I downloaded the .msi I ran it and then the program closed. I have no idea where the files are ???

Can anyone advise on how to locate and import the file so I need to get my program to run?


Running the .msi file is supposed to start a windows installer. It is not supposed to end silently -- perhaps you can give more details on what you did?

Henry
 
J Noble
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI there,

I went to http://dev.mysql.com/downloads/connector/j/ and downloaded the only option avaiable to me. When I installed it, it ended silently as you say so I had no idea what had happenned.

However, I think I think I have solved it.

I went to the mysql site and downloaded the zip version (under previous versions). I extracted it and found the file that I needed.

I then right click on the project -> Build Path and added the file to the project.

All works as expected now.

Thanks,


J
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J Noble wrote:
However, I think I think I have solved it.

I went to the mysql site and downloaded the zip version (under previous versions). I extracted it and found the file that I needed.

I then right click on the project -> Build Path and added the file to the project.

All works as expected now.


Thanks for reporting back on the solution ... you earned a cow.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!