Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jdbc exception

 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yu Tao
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic