-
JDBC Driver for SQL Server 2005, Class not found Exception (4 messages)
- Posted by: Ran jith
- Posted on: May 15 2007 09:46 EDT
Hai, i am tried to use the Sql Server with Java and Tomcat 5.0 Application Server. I am using the JDBC Driver for Java connecting with SQL Server. I am using SQL Server 2005. But the JDBC Connection doesn't create. I have used the following code for java database connectivity with SQL Server. import java.sql.*; public class Test { public static void main(String[] args) { try { //load the driver class Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://127.0.0.1:1433; DatabaseName=timetracking "); } catch(ClassNotFoundException cnfe) { System.err.println(cnfe); } catch (SQLException sqle) { System.err.println(sqle); } The above code was compiled successfully, but it's not running. The below error was raised. I have coped and paste it the JDBC Driver class for SQL Server 2005(sqljdbc.jar) to the WEB-INF/lib folder. java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver I don't know what i am doing with wrong. If anybody know, how to solve this, kindly post me. Thanks TamilvananThreaded Messages (4)
- Re: JDBC Driver for SQL Server 2005, Class not found Exception by Fernando Ramos on May 18 2007 13:15 EDT
- JDBC Driver for SQL Server 2005, Class not found Exception by Kl;K Lkl on June 16 2007 03:50 EDT
- tomcat 5.0.x + sql server 2005 + eclipse 3.3; jdbc error by david gonzalez on January 07 2010 19:32 EST
- How to: SQL in Java by shahriar khondokar on June 14 2010 10:28 EDT
-
Re: JDBC Driver for SQL Server 2005, Class not found Exception[ Go to top ]
- Posted by: Fernando Ramos
- Posted on: May 18 2007 13:15 EDT
- in response to Ran jith
try to put the driver .jar file in the following directory $TOMCAT_HOME\common\lib Regards, Fernando. -
JDBC Driver for SQL Server 2005, Class not found Exception[ Go to top ]
- Posted by: Kl;K Lkl
- Posted on: June 16 2007 03:50 EDT
- in response to Ran jith
There are few things 1.download the driver for JDBC sql server 2005 and put it in your classpath. this is important 2. load driver class is OK. 3. remove microsoft from the string jdbc:microsoft:sqlserver://127.0.0.1:1433; DatabaseName=timetracking "jdbc:sqlserver://127.0.0.1:1433;" the error you are getting is beacause the exact class is not in the classpath i think you are using the old driver which is for 2000. -
tomcat 5.0.x + sql server 2005 + eclipse 3.3; jdbc error[ Go to top ]
- Posted by: david gonzalez
- Posted on: January 07 2010 19:32 EST
- in response to Kl;K Lkl
Hi. I have followed almost everything in this thread and another forums and no way. Always I get: Cannot create JDBC driver of class '' for connect URL 'null' java.sql.SQLException: No suitable driver Curiosly when I use tomcat 6.0.x and the other definition in context.xml I have no problems, everything works ok, so I understand the problem is in this configuration file. I'm trying to connect to my sql server 2005 Express Edition from my eclipse project using tomcat 5.0.28 1.- Copied the sqljdbc.jar (1.2) in /common/lib 2.- Put the slqjdbc.jar in Path (pointing to /common/lib) 3.- Specify the ports in sql server 2005 and add use TCP/IP 4.- I use context.xml in META-INF and this is the content of the file: <?xml version="1.0" encoding="UTF-8"?> factory org.apache.commons.dbcp.BasicDataSourceFactory driverClassName com.sqlserver.microsoft.jdbc.SQLServerDriver url jdbc:sqlserver://127.0.0.1\SQLEXPRESS:1433;DatabaseName=myDB User myuser Password mypassword maxActive 20 maxIdle 10 maxWait -1 removeAbandoned true removeAbandonedTimeout 300 logAbandoned true 5.- In web.xml I have added the next code: DB Connection jdbc/myDB javax.sql.DataSource Container Any suggestions. thanks in advance -
How to: SQL in Java[ Go to top ]
- Posted by: shahriar khondokar
- Posted on: June 14 2010 10:28 EDT
- in response to Ran jith
Check this article HOW TO: SQL in JAVA for details on how to connect to SQL Server database from C#.NET database applications as well as Java database applications. It also describes how to pass embedded SQL queries (SELECT, INSERT, UPDATE, DELETE), calling stored procedures, pass parameters etc.