Solved

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

Posted on 2004-04-20
19
308 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

19 Experts available now in Live!

Get 1:1 Help Now