Solved

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

Posted on 2004-04-20
19
313 Views
Last Modified: 2010-04-01
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!
0
Comment
Question by:chijingao
  • 11
  • 8
19 Comments
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869282
which class is it not able to find?

try adding this to the top of your jsp page:

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

/Nick
0
 

Author Comment

by:chijingao
ID: 10869303
Class.forName(
                                "com.microsoft.jdbc.sqlserver.SQLServerDriver");

is wrong!
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869310
Please post the whole error message you get when it shows ClassNotFoundException.
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869315
oh ok...

then you'll need to put the zip file with the MS SQL server jdbc driver in the webapps /lib folder
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869340
{Tomcat home}\webapps\yourwebapp\WEB-INF\lib
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869345
then restart Tomcat
0
 

Author Comment

by:chijingao
ID: 10869354
i don't have a zip file. I have a setup.exe!
 
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869383
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
0
 

Author Comment

by:chijingao
ID: 10869395
I have done it before i came here :(
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:Nick_72
ID: 10869423
did you copy them to you webapps lib folder under tomcat??
0
 

Author Comment

by:chijingao
ID: 10869424
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\
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869435
alright then, copy the zip files to

{Tomcat home}\webapps\Root\WEB-INF\lib
0
 

Author Comment

by:chijingao
ID: 10869439
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
0
 

Author Comment

by:chijingao
ID: 10869450
o. I copied it now {Tomcat home}\webapps\Root\WEB-INF\lib.


let me try it..
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869468
remember to restart tomcat first :)
0
 

Author Comment

by:chijingao
ID: 10869471
it works well!!!!!!!!!

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

thanks a lot agian.
0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10869505
No problem :)
0
 
LVL 9

Accepted Solution

by:
Nick_72 earned 125 total points
ID: 10869537
But please remember to hit the 'Accept' button ;)
0
 

Author Comment

by:chijingao
ID: 10943006
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A customer recently asked me about anti-malware and the different deployment options available for his business. Daily news about cyberattacks, zero-day vulnerabilities, and companies that suffered a security breach made him wonder if the endpoint a…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now