wood burning stoves 2.0*
The moose likes JDBC and the fly likes can't find jdbc driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "can Watch "can New topic
Author

can't find jdbc driver

Kevin Cary
Ranch Hand

Joined: Jan 24, 2001
Posts: 53
My application can't find jdbc driver. My app is located
c:\windows\database and driver is located
c:\windows\database\msql. I am importing the msql directory.
My app comes up with about 67 errors. What am I doing wrong?
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Is the driver in your classpath?
------------------
Moderator of the JDBC Forum


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Kevin Cary
Ranch Hand

Joined: Jan 24, 2001
Posts: 53
Yes, my MsqlDriver() is in the class path. But for some reason my app isn't finding the driver when I try to create an instance using new MsqlDriver();.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
How is it in your classpath?
If it's in a jar file then the jar file must be in the classpath. If it's a regular class then everything up to but not including the package must be included in the classpath. Example:
Class is in: /myjava/lib/com/msql/MsqlDriver
MsqlDriver is in the package com.msql
the classpath must have /myjava/lib in it. Not /myjava/lib/com/msql.
It seems that the driver is probably not in the correct directory since drivers are almost always part of a package and you don't appear to have it in the package structured directories.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
This is an example of how you can create a connection to a MySQL database using the mmsql JDBC driver:

This example was shamelessly ripped off from Mark Matthews' mySQL documentation. I included it because you mentioned this:

...when I try to create an instance using new MsqlDriver();.

I have never created an instance of a JDBC driver using the "new" keyword, and I wondered if this might be your problem.
[This message has been edited by Bodie Minster (edited April 19, 2001).]
Kevin Cary
Ranch Hand

Joined: Jan 24, 2001
Posts: 53
SET CLASSPATH=.;C:\PROGRA~1\JMF21~1.1_B\LIB\SOUND.JAR;
C:\PROGRA~1\JMF21~1.1_B\LIB\JMF.JAR;
C:\JDK1.3\LIB;
Sample Code:
Class.forName( "com.msql.MsqlDriver");
Using:
Class.forName( "com.msql.MsqlDr~1" );
still complains at run time but not as much. Which is to say it can't find the driver.
Driver is located this directory C:\JDK1.3\LIB\com\msql
This looks good to me. What do you think?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
My next step would be to open the JAR and look for the class by hand. If you can locate it, try extracting it and using it from outside the JAR. If you can't locate a .CLASS file in the JAR with the name MsqlDriver.class then that is the reason your code is failing. I don't think you will be able to reference a class file using the ~ notation that windows uses to compress long filenames. That notation makes the compiler angry. You will have to use the full class name.
 
 
subject: can't find jdbc driver