General J2EE: JDBC Driver for SQL Server 2005, Class not found Exception

  1. 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://; 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 Tamilvanan
  2. try to put the driver .jar file in the following directory $TOMCAT_HOME\common\lib Regards, Fernando.
  3. 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://; DatabaseName=timetracking "jdbc:sqlserver://;" 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.
  4. 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://\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
  5. How to: SQL in Java[ Go to top ]

    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.

    Shahriar Nour Khondokar