Solved

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

Posted on 2004-04-20
19
314 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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