You might get below error while using Commons DBCP , even if you have correct JDBC driver in your classpath.
When you run it in standlone java program , you get error like this :
java.lang.UnsupportedOperationException: Java Runtime Environment (JRE) version 1.7 is not supported by this driver. Use the sqljdbc4.jar class library, which provides support for JDBC 4.0. at com.microsoft.sqlserver.jdbc.SQLServerConnection.(SQLServerConnection.java:238) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841) at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582) at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556) at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545) at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388) at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044) at io.estation.services.GoogleServices.downloadWebMasterToolReport(GoogleServices.java:152) at io.estation.services.rest.RestServices.testWm(RestServices.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)
When you run it in standlone java program , you get error like this :
WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:c4ecd18c-82f8-4e5b-a932-66d840a18532 at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667) at com.microsoft.sqlserver.jdbc.AuthenticationJNI.Turns out that in your jdbc string you are using integratedSecurity=true, this causes the Commons DBCP to throw error like this , which is not really actual error .(AuthenticationJNI.java:60) at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2229) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41) at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:1326) at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at executeCommandTest.JDBCTest.main(JDBCTest.java:14) Caused by: java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.loadLibrary0(Unknown Source) at java.lang.System.loadLibrary(Unknown Source) at com.microsoft.sqlserver.jdbc.AuthenticationJNI. (AuthenticationJNI.java:35) ... 12 more
jdbc:sqlserver://localhost;databaseName=msdb;integratedSecurity=trueRemove this , and you will be fine .