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);
Read Tomcat Documentation about classpath for clarification or just put the sqljdbc.jar in $CATALINA_HOME/lib to access it from all your applications.
You need to add the jar file containing the class com.microsoft.sqlserver.jdbc.SQLServerDriver
to your war file's WEB-INF/lib
folder.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With