Using MS-Sql
server with JSP
Please help me in using Sqlserver with my jsp. I have installed jdbc
driver for sqlserver and added the three jar files in my class path.
When I compile a simple java program to test my driver I am getting
error.
Also if any body gives me the correct procedure and steps for using
it will be more helpful.
public class Test {
public Test() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://comp1:1433","","");
if (connection != null) {
System.out.println();
System.out.println("Successfully
connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name:
"
+ meta.getDriverName());
System.out.println("Driver Version:
"
+ meta.getDriverVersion());
System.out.println("\nDatabase Information
");
System.out.println("Database Name:
"
+ meta.getDatabaseProductName());
System.out.println("Database Version:
"+
meta.getDatabaseProductVersion());
}
}
public static void main (String args[]) throws Exception
{
Test test = new Test();
}
}
When I compile the above code, I am getting error like this
com/microsoft/jdbc/sqlserver/SQLServerDriver() not found
GokulBabu Kuttuva
The error says that that driver not found... so you need to set your
class path right...
Otherwise... copy your driver file and paste it in your run time environment..
probably..
c:\program files\java\jsdk...\lib\ext and that should work for
you...
Kata
You need to add all the 3 jar files in to the web server class path
.For eg if you are using TomCat web server then you need to add all 3 jar
files in to the catalina.bat file's class path variable to recognise SQLServerDriver().
Hope this will solve your problem.
Sandhya Rani
Do one thing,Download the driver from Website (New Version)and installed
at your System.and set the path for same. Compile the Prog. You will be
definately getting Result.
Prasanna
Just copy all your jar files into the folder
yourProjectName/WEB-INF/lib/
directory....
Restart the tomact....
That's it!!!!!!
Somanath
Do you have a Java Problem?
Ask It in The Java
Forum
Java Books
Java Certification,
Programming, JavaBean and Object Oriented Reference Books
Return to : Java
Programming Hints and Tips
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.erpgreat.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.erpgreat.com or the content authors.
|