This is crazy! I have been through all the forums and a lot of books. I use NetBeans 5.0 and I have an app accessing MySQL database through mysql-connector-java-3.1.12 and when I use it from NetBeans it works ok, but after I build it and attempt to use it than it shows a classNotFoundException and names the driver I instantiated with
what type of application is it. j2ee or se. Either way the jar that contains the driver must be on the classpath. How you accomplish this depends on the type of application.
Maybe youre IDE hasnt added the connector to the classpath yet. Youre IDE should allow you to add a jar to the classpath. Sometimes, you can include a jar in a project but unless you actually instruct the ide to add that jar to the build path, it wont include it.
In any case...this always works for me (in Eclipse) :
Class.forName("com.mysql.jdbc.Driver");
//blah is the database name Connection con= DriverManager.getConnection("jdbc:mysql://localhost/blah", "user", "1234");
Branko Santo
Ranch Hand
Joined: Oct 15, 2005
Posts: 72
posted
0
It is an J2SE application, and I do attach the .jar with the connector to the project and when I just run it from IDE it runs ok, but if I build and than run it, it does not work.
Class.forName("com.mysql.jdbc.Driver"); //blah is the database name Connection con= DriverManager.getConnection("jdbc:mysql://localhost/blah", "user", "1234");
Thanks I will try that out. Is there a possibility to make a batch file so that it is always started up with that invocation? Since I cant have users typing that all the time
Was that question meant to be "How do I type commands into a batch file?" Surely it wasn't, the answer to that is "With a keyboard and a text editor program". I must not be understanding your problem correctly.
Assuming that your program needs just the admin.jar and mysql.jar, put the two jar files in the same directory, open a command prompt in that directory and type:
Then assuming that works, create a new text file in the same directory, paste in the command above, then rename the file to admin.bat. Be careful that windows doesn't rename it to windows.bat.txt, it does that some times. Double clicking the batch file should run your program
Branko Santo
Ranch Hand
Joined: Oct 15, 2005
Posts: 72
posted
0
Paul yes actually I did not know how to make a batch file
David thanks a million, batch file works, program runs but still gives the esception. But I hacked it just took the source code of the Driver class and copied the whole class in my program. It works that way.
Thanks everybody once more it has been a pleasure Hopefully I will be able to help all you one day