JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat 
Author Message
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat

I am a NEWBIE is using JDBC and trying to use it to connect to my MS
SQLServer 2000. Right now, I have written a java program using the
simplest method with the snippet code shown below

Driver d=(Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433",
"userName", "password");

I have set my classpath variable as follow :

CLASSPATH=.;c:\program files\Microsoft SQL Server 2000 Driver for
JDBC\lib\msbase.jar;c:\program files\Microsoft SQL Server 2000 Driver
for JDBC\lib\msutil.jar;c:\program files\Microsoft SQL Server 2000
Driver for JDBC\lib\mssqlserver.jar

I can connect to the Database Server successfully.

However, I encounter problem when I change my program into servlet.
The error message is "java.lang.ClassNotFoundException:
com/microsoft/jdbc/sqlserver/SQLServerDriver". The servlet program is
now run under TomCat v4.1.x.

Hence, I would like to know if there is any extra setup needed in
TomCat so that it can recognise those jar files.

Would any professionals offer some help for me ? Thanks a lot!

Regards
Samuel



Sat, 16 Jul 2005 10:35:05 GMT
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat

I get the same exact problem. Is there something that we are missing?

Quote:
> I am a NEWBIE is using JDBC and trying to use it to connect to my MS
> SQLServer 2000. Right now, I have written a java program using the
> simplest method with the snippet code shown below

> Driver

d=(Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Quote:
> con =

DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433",
Quote:
> "userName", "password");

> I have set my classpath variable as follow :

> CLASSPATH=.;c:\program files\Microsoft SQL Server 2000 Driver for
> JDBC\lib\msbase.jar;c:\program files\Microsoft SQL Server 2000 Driver
> for JDBC\lib\msutil.jar;c:\program files\Microsoft SQL Server 2000
> Driver for JDBC\lib\mssqlserver.jar

> I can connect to the Database Server successfully.

> However, I encounter problem when I change my program into servlet.
> The error message is "java.lang.ClassNotFoundException:
> com/microsoft/jdbc/sqlserver/SQLServerDriver". The servlet program is
> now run under TomCat v4.1.x.

> Hence, I would like to know if there is any extra setup needed in
> TomCat so that it can recognise those jar files.

> Would any professionals offer some help for me ? Thanks a lot!

> Regards
> Samuel



Sat, 16 Jul 2005 14:04:35 GMT
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat
Not sure, but you can check out a couple of things:

* Make sure your import statement matches that of the package
declaration for the driver
* Try dumping the driver's JAR file into your app's WEB-INF/lib folder.

When you get it working, please share with us the solution.

Good luck,
epp



Sun, 17 Jul 2005 00:05:44 GMT
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat

Quote:

> I am a NEWBIE is using JDBC and trying to use it to connect to my MS
> SQLServer 2000. Right now, I have written a java program using the
> simplest method with the snippet code shown below

> Driver d=(Driver)Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
> con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433",
> "userName", "password");

> I have set my classpath variable as follow :

> CLASSPATH=.;c:\program files\Microsoft SQL Server 2000 Driver for
> JDBC\lib\msbase.jar;c:\program files\Microsoft SQL Server 2000 Driver
> for JDBC\lib\msutil.jar;c:\program files\Microsoft SQL Server 2000
> Driver for JDBC\lib\mssqlserver.jar

> I can connect to the Database Server successfully.

> However, I encounter problem when I change my program into servlet.
> The error message is "java.lang.ClassNotFoundException:
> com/microsoft/jdbc/sqlserver/SQLServerDriver". The servlet program is
> now run under TomCat v4.1.x.

> Hence, I would like to know if there is any extra setup needed in
> TomCat so that it can recognise those jar files.

> Would any professionals offer some help for me ? Thanks a lot!

> Regards
> Samuel

Tomcat 4.1 does not use CLASSPATH environment variable. Edit
setclasspath.bat in tomcats bin directory to include your databasedriver
jars.

  - Kari



Sun, 17 Jul 2005 03:59:03 GMT
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat

I think the Tomcat docs would say that you've got to have the JDBC
driver jar in %TOMCAT_HOME%\common\lib.  Tomcat will find it there.
Editing the CLASSPATH is a bad idea.

Which driver are you using?  I've gone with jTDS at:

http://jtds.sourceforge.net

It works well. - MOD

--
Posted via http://dbforums.com



Tue, 26 Jul 2005 03:10:25 GMT
 JDBC Connection Problem "CLASSNOTFOUNDEXCEPTION" in TomCat
Thanks for duffymo & Kari

I have tried both of your suggestions. It works.

Best regards
Samuel

Quote:

> I think the Tomcat docs would say that you've got to have the JDBC
> driver jar in %TOMCAT_HOME%\common\lib.  Tomcat will find it there.
> Editing the CLASSPATH is a bad idea.

> Which driver are you using?  I've gone with jTDS at:

> http://jtds.sourceforge.net

> It works well. - MOD



Thu, 28 Jul 2005 08:39:23 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. Help - JDBC "thin" Connection problem

2. JDBC "Closed connection" between JSP pages

3. "Newbie" JDBC connection pooling question

4. max of ("...","...","..")

5. JDBC&MySQL connection problem: "Unable to load driver!" "No suitable driver!"

6. interbase JDBC problem "unitialized object"

7. Problems setting up PostgreSQL and Tomcat JDBC connection

8. Problems with "Trusted Connection" login

9. transfer problem - "max connections exceeded"

10. problem with "Maximum concurrent user connection"

11. More on "User Connection" problem

12. Help ! Oracle-Tomcat-jdbc-connection-Problem


 
Powered by phpBB® Forum Software