aspose file tools*
The moose likes JSP and the fly likes connecting JSP to SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "connecting JSP to SQL Server" Watch "connecting JSP to SQL Server" New topic
Author

connecting JSP to SQL Server

evan theon
Ranch Hand

Joined: Feb 16, 2005
Posts: 39
have a problem connecting JSP to SQL Server 2000 i have done these following steps :
i have download and install the j2sdk 1.4.2
then i have set the JAVA_HOME in the Environment Variables to the directory where j2sdk is installed
then i have download and install Tomcat 4.1 from apache.org
then i have set the CATALINA_HOME in the Environment Variables to the directory where Tomcat 4.1 is installed
then i have download the sqlserver JDBC driver from :
1.http://download.microsoft.com/download/4/4/8/448af92b-e571-4bb2-810f-46be921a718c/setup.exe
2.and from http://prdownloads.sourceforge.net/jtds/jtds-1.1-dist.zip?download

from file number 1 i have run the setup.exe and then copy the msbase.jar, msutil.jar, and mssqlserver.jar from the directory sql server JDBC driver installed to the Tomcat 4.1/common/lib.

From file number 2 i have extract the file and copy the jtds-1.1.jar file into the Tomcat 4.1/common/lib

the coding to connect is as follow (for each file, i have tried both files):
1.Class.forName(�com.microsoft.jdbc.sqlserver.SQLServerDriver�);
Connection conn = DriverManager.getConnection(�jdbc:microsoft:sqlserver://servername:1433;user=sa;Password=admin;DatabaseName=Northwind�);
2.Class.forName(�net.sourceforge.jtds.jdbc.Driver�).newInstance();
Connection conn = DriverManager.getConnection(�jdbc:jtds:sqlserver://servername:1433;user=sa;Password=admin;DatabaseName=Northwind�);

after i run the JSP file, i got a ClassNotFoundException for both driver ( com.microsoft.jdbc.sqlserver.SQLServerDriver and net.sourceforge.jtds.jdbc.Driver )
is there anything i haven't done???

for additional information i have tried to set CLASSPATH in the Environment Variables just to have the same result. I also tried to copy the tools.jar from the j2sdk/lib to the Tomcat/common/lib but it appears that the file is already exist.

Please help..........

thank you all
[ September 08, 2005: Message edited by: Bear Bibeault ]
evan theon
Ranch Hand

Joined: Feb 16, 2005
Posts: 39
please help.... i really need to know why it won't work....thank you very much
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

after i run the JSP file, i got a ClassNotFoundException for both driver ( com.microsoft.jdbc.sqlserver.SQLServerDriver and net.sourceforge.jtds.jdbc.Driver )


ClassNotFound means, simply, that.
You might want to check to see that you've got the spelling and case correct.
You can do this by CDing to the directory where your jar file is (common/lib)
and typing:
jar tvf myLib.jar;

If it's really long, you can redirect to a file with:
jar tvf myLib.jar > lib-description.txt

The "t" switch will dump a list of all the files (with paths) within the jar file to stdout.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
evan theon
Ranch Hand

Joined: Feb 16, 2005
Posts: 39
i've tried to check the spelling, and i double check it, but i found there's no mistakes about it.....i thank you very much for your help but if there's any further explanation for me to had i would very appreciate it...

thank you
evan theon
Ranch Hand

Joined: Feb 16, 2005
Posts: 39
i've already connected to the database..... it appeared to be my fault i copied the driver's jar file into Tomcat 4/common/lib instead of WEB-INF/lib/


thanks for all your help guys!
but anyway, i got another weird happens here...after i succesfully configured all those things on my PC then i want to do the same thing on my laptop. but it didn't work.....
is there any different configuration needed between windows XP pro and windows XP Home in this case? because my PC is operated by win XP Pro while my laptop is operated by win XP home
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connecting JSP to SQL Server
 
Similar Threads
JDBCRealm and MS SQL Server
Java and MS SQL Server 2000
JDBC Connection without DSN .and Type 4 Driver
SQL Server connect works in IDE but not in exported JAR
tomcat - mysql : Connection refused