aspose file tools*
The moose likes JDBC and the fly likes jdbc exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc exception" Watch "jdbc exception" New topic
Author

jdbc exception

Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
hi all,

i have downloaded "SQL Server 2000 Driver for JDBC Service Pack 3" from the microsoft site and have set the classpath accordingly. still, i get an exception
java.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver

what could possibly be wrong in this? my registration of the driver is done as
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");

any help is appreciated.

cheers,
Anandh


cheers,<br />Anandh
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

That is the name of the driver, so you must have made a mistake in how you set the classpath. How are you doing that?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Anandh,


and have set the classpath accordingly

No you haven't, because if you had, you wouldn't be getting the "ClassNotFoundException".

Perhaps you made a mistake, or you do not properly understand how to set your CLASSPATH. Either way, as Paul says, you may have a better chance at getting some help if you post more details on how you set your CLASSPATH.

Good Luck,
Avi.
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
this is my classpath. i have installed the driver in the directory c:\sqdriver

D:\jakarta-tomcat-3.3.1\lib\common\servlet.jar;C:\Program Files\Apache Group\Tomcat 4.1\shared\classes;C:\Program Files\Apache Group\Tomcat 4.1\common\lib\servlet.jar;C:\Program Files\Apache Group\Tomcat 4.1\common\lib\jasper-runtime.jar;D:\jakarta-tomcat-3.3.1\lib\common\jasper-runtime.jar;C:\Program Files\Apache Group\Tomcat 4.1\common\lib;C:\Program Files\Apache Group\Tomcat 4.1\common\lib\mail.jar;C:\Program Files\Apache Group\Tomcat 4.1\common\lib\naming-resources.jar;C:\sqdriver\lib\msbase.jar;C:\sqdriver\lib\mssqlserver.jar;C:\sqdriver\lib\msutil.jar;.;
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Anandh,
I believe java has trouble handling directory names with spaces in them.
I suggest using the short names instead.
In any case, if you are using a simple java class, then you don't need
all that other stuff in your CLASSPATH (like "servlet.jar").
Usually I supply the CLASSPATH using the command-line option, as in:

Good Luck,
Avi.
Anandh Ramesh
Ranch Hand

Joined: Dec 15, 2004
Posts: 61
Hi Avi,

the last three jar files were all that was added by me for the driver. the other files are for the ongoing project and the project is working fine. my problem is only in the last three jar files' inclusion. the class i am looking for is in the 'sqlserver' jar file.

cheers,
Anandh
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Anandh Ramesh:
...C:\sqdriver\lib\mssqlserver.jar...
You didn't happen to name the directory on disk "sqldriver" with an l in there (for SQL) did you? Or did it suggest "sqdriver" to keep it at 8 characters?

If that's not it, I'd write a tiny test class who's main method only does the Class.forName() on the driver. Compile it and run it with a classpath containing only those three JARs. Heck, run it from the directory containing the JARs so you can eliminate directory issues.

Simplify the problem down to a point where it will be obvious that it should work or not. Then add complexity until you find the problem.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The other thing I would do is verify the path within the jar file.
Make sure: com.microsoft.jdbc.sqlserver.SQLServerDriver is spelled right and has the proper casing.

"jar -tf mssqlserver.jar" will show you the contents of the jar file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Yu Tao
Greenhorn

Joined: Dec 12, 2004
Posts: 28
goto microsoft and download JDBC Driver

after setup the Dirver you can see three JAR.

copy this three JAR to JAVA_HOME/jre/lib/ext

just OK!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc exception