This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
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();.
Joined: May 05, 2000
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.
...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).]
Joined: Jan 24, 2001
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?
Joined: Nov 22, 2008
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.