Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

sql

jdbc

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

I got the above exception when i trying to deploying my Application into tomcat. but the weird thing is , i tried with a simple main method and it's works fine. Any help please ???

I did 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);
like image 599
user2171503 Avatar asked Mar 14 '13 20:03

user2171503


4 Answers

Read Tomcat Documentation about classpath for clarification or just put the sqljdbc.jar in $CATALINA_HOME/lib to access it from all your applications.

like image 41
Krystian Lieber Avatar answered Nov 07 '22 19:11

Krystian Lieber


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

like image 77
Asaph Avatar answered Nov 07 '22 19:11

Asaph


Eventhough you have JAR(sqlserverjdbc.jar) in build path You need to add the jar file containing the class. com.microsoft.sqlserver.jdbc.SQLServerDriver to your war file's WEB-INF/lib folder.

like image 2
Govardhan Chary Avatar answered Nov 07 '22 20:11

Govardhan Chary


May 15, 2014 3:09:43 PM org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: Unable to create initial connections of pool. 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) ...

It is quite puzzling because my web application has WEB-INF/lib/sqljdbc4.jar.

From the error message, somehow the jar file is required by Tomcat too.

After I copy the jar file to CATALINA_HOME/lib/sqljdbc4.jar, the error is gone.

like image 2
oraclesoon Avatar answered Nov 07 '22 21:11

oraclesoon