Java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

I got the above exception when trying to deploy my application to tomcat. but the strange thing is, I tried with a simple basic method and it works great. Any help please ???

I have done the following:

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
String connectionUrl = "jdbc:microsoft:sqlserver://localhost:1433;" + "database=DBName;" + "user=UserName;" + "password=Password";
connection = DriverManager.getConnection(connectionUrl);
+5
source share
5 answers

You need to add the jar file containing the class com.microsoft.sqlserver.jdbc.SQLServerDriverto the war file folder WEB-INF/lib.

+6
source

Read the “Tomcat Class Path Documentation” for clarification or simply put sqljdbc.jar in $ CATALINA_HOME / lib to access it from all your applications.

+3
source

JAR (sqlserverjdbc.jar) , jar, . com.microsoft.sqlserver.jdbc.SQLServerDriver WEB-INF/lib.

+2

15 2014 3:09:43 PM org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: . java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver         at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)         at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)         at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)         at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)...

, - WEB-INF/lib/sqljdbc4.jar.

, - Tomcat.

After copying the jar file to CATALINA_HOME / lib / sqljdbc4.jar, the error went away.

+2
source

Since you are using a web application, you need to have a MS SQL Server driver or a driver for any database stored in two places. Inside the application, which will become your WAR, and then you need a second copy, which is stored in the LIB directory of the application server. So, if you work on Tomcat, you would put it / opt / tomcat / lib or C: \ DEV \ tomcat7 \ lib.

0
source

All Articles