I have recently migrated from MS-Access to MySQL (recommendation of this forum) anyway, it works fine with my IDE (conn to db is working) but not when I "JAR" the java class and run it from the command line (I get: com.mysql.jdbc.Driver).
Now, when I used MS Access db I 'showed' the computer that the database I'm talking about is: Start-->Control Panel-->Administrative tools-->Data Source(ODBC) and then configuring it with the System DSN.
Questions: 1. How do I do that in MySql ?? ? ? (I don�t have the driver?! There�s only SQL Server) 2. How does the computer 'know' which database I'm talking about???
You need to have a manifest file in your JAR with a CLASSPATH argument that points to the Connector/J jar file. You should also be able to put the Connector/J jar file on your system CLASSPATH, but the manifest is a more portable way.
C:\Documents and Settings\Peter\Desktop\t>java TestMysql => loading driver:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 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.ClassLoader.loadClassInternal(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at TestMysql.main(TestMysql.java:12)
Joined: Dec 29, 2004
I can't think of anything it can be other than a classpath issue, sorry.
Joined: Sep 10, 2004
Steven Thanks a lot!!!
you mention classpath and that's the KEY!!! I got it. I used the wrong connector.
THANKS it works...one question however, say I want to share the database on a network so other computers can access my databsae, how do i do that???
In MS access I used the Start-->Control Panel-->Administrative tools-->Data Source(ODBC) and then configuring it with the System DSN.
Do you know how to do it with MySQL???
Joined: Dec 29, 2004
With MySQL it is already shared, you only have to set up a user with the proper access. I think the MySQL Administrator tool will do that. MySQL also distinguishes localhost users from external users so make sure you set up the right kind of user.
Glad to hear you got things working.
P.S. With the Access DB you were using, were you connecting to that with a Java app? If so what were you using? Also are you using the same table setup or are they different and how did you move the data over? I only ask because I need to move data from an Access DB over to a MySQL DB, but the table structure is very different (I swear the old Access DB was setup by a monkey ). [ March 05, 2005: Message edited by: Steven Bell ]