This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes I get error with driver:may have mysql 5.1 and driver is for 5.0? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I get error with driver:may have mysql 5.1 and driver is for 5.0?" Watch "I get error with driver:may have mysql 5.1 and driver is for 5.0?" New topic
Author

I get error with driver:may have mysql 5.1 and driver is for 5.0?

Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
I get error with driver:

C:\Users\User\Documents\TextBooksDataFiles\JAVA\xml-java\Examples12\Examples\Example 12-1 2-tier JDBC QUERY Example>javac DatabaseAccess.java

C:\Users\User\Documents\TextBooksDataFiles\JAVA\xml-java\Examples12\Examples\Example 12-1 2-tier JDBC QUERY Example>java DatabaseAccess
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at DatabaseAccess.main(DatabaseAccess.java:11)

C:\Users\User\Documents\TextBooksDataFiles\JAVA\xml-java\Examples12\Examples\Example 12-1 2-tier JDBC QUERY Example>

folder contains DatabaseAccess.java and mysql-driver.jar (2004) , may have mysql 5.1 and driver is for 5.0?


success
INSERT INTO claim
VALUES (1,'B2007-11-051','Broken window',150.00,true,'2007-05-11',1);
INSERT INTO claim
VALUES (2,'C2007-04-131','Stained carpet',1000.00,false,'2007-04-13',2);
INSERT INTO claim
VALUES (3,'C2007-22-011','Stolen camera',650.00,true,'2007-01-22',2);
INSERT INTO claim
VALUES (4,'B2007-04-011','House burned down',350000.00,true,'2007-01-04',3);

Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

You have to add that driver to your classpath when running your code. Putting it in that directory does not help (and I would not reccomend you to do that).

OCUP UML fundamental and ITIL foundation
youtube channel
Leonidas Savvides
Ranch Hand

Joined: Jan 31, 2010
Posts: 403
problem solved thks!...

 
 
subject: I get error with driver:may have mysql 5.1 and driver is for 5.0?
 
Similar Threads
I found that inner classes cause problem run my jar file (no problem making the jar or compiling),
Creating a database with Sun Java Application Server 9
error in transform from database-to->xml-to->xhtml:The XML page cannot be displayed
how check javabean giving to other component correct data
Error in struts appeared when go to run a script with LogFactory, Log classes but I continue run non