Link to home
Start Free TrialLog in
Avatar of chijingao
chijingao

asked on

*.java can connect with JDBC, but *.JSP can not connect with JDBC

hi, Here is my problem

My ''Testconnect.java'' file works well. it could connect a JDBC.
But when I copy the same code to  test.asp file, it didn't work.
I got a classNotFoundException.

the two progrma is fairly simple. I don't know what is wrong.


tomcat 5.0
Win xp
JSDK 1.4
SQL server 2000
JDBC for SQL server 2000

thanks!
Avatar of Nick_72
Nick_72

which class is it not able to find?

try adding this to the top of your jsp page:

<%@ page import="java.sql.*"%>

/Nick
Avatar of chijingao

ASKER

Class.forName(
                                "com.microsoft.jdbc.sqlserver.SQLServerDriver");

is wrong!
Please post the whole error message you get when it shows ClassNotFoundException.
oh ok...

then you'll need to put the zip file with the MS SQL server jdbc driver in the webapps /lib folder
{Tomcat home}\webapps\yourwebapp\WEB-INF\lib
then restart Tomcat
i don't have a zip file. I have a setup.exe!
 
ok, but when you run the setup.exe, you will install it to some place on the disc, then take the 3 zip files from the lib folder of that installation and copy them to your webapp's lib folder.

The path could look something like this:

C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib
I have done it before i came here :(
did you copy them to you webapps lib folder under tomcat??
o wait I am new..

what is {Tomcat home}\webapps\yourwebapp\WEB-INF\lib  ??

I just put all my files under {Tomcat home}\webapps\Root\
alright then, copy the zip files to

{Tomcat home}\webapps\Root\WEB-INF\lib
I have three *.jar files under C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib

I copied them to C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib
o. I copied it now {Tomcat home}\webapps\Root\WEB-INF\lib.


let me try it..
remember to restart tomcat first :)
it works well!!!!!!!!!

thanks a lot.
It is the first time I come here.

thanks a lot agian.
No problem :)
ASKER CERTIFIED SOLUTION
Avatar of Nick_72
Nick_72

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
note: it didn't work again two days later. Sql 2000 server patch 3 is also needed. i installed it and now every thing is OK.