Tomcat8 load error incorrect SQL Server Driver / SQLServerXADataSource not found

I am trying to set up a connection pool using com.microsoft.sqlserver.jdbc.SQLServerXADataSource

Tomcat8. Although everything is fine, using com.microsoft.sqlserver.jdbc.SQLServerDriver

, when used SQLServerXADataSource

, Tomcat claims No suitable driver found

.

I'm sure the correct driver flags are in $CATALINA\lib

, but I'm not sure if it's loaded correctly as it com.microsoft.sqlserver.jdbc.SQLServerDriver

works with and without this driver in lib

. There may be another driver loaded that I could not find.

Similar issue for Windows and OS X so far ...

Does anyone know how to solve this?

UPDATE: Im setting up my datasource in code like:

//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerXADataSource");
  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  final ConnectionFactory                     connectionFactory         = new DriverManagerConnectionFactory(connectURI, null);
  final PoolableConnectionFactory             poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory, null);
  final GenericObjectPool<PoolableConnection> connectionPool            = new GenericObjectPool<>(poolableConnectionFactory);
  poolableConnectionFactory.setPool(connectionPool);
  return new PoolingDataSource<>(connectionPool);

      

+3


source to share


2 answers


There seems to be no known way to do this in code. However, I was able to set it up using



<Resource name="jdbc/mssql"
          auth="Container"
          type="javax.sql.XADataSource"
          driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
          username="XXX"
          password="XXX"
          url="JDCB Connection String"
          factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
        />

      

0


source


This configuration should work. Make the necessary changes to the corresponding values:



<Resource name="jdbc/mssql" 
              auth="Container"
              type="com.microsoft.sqlserver.jdbc.SQLServerXADataSource"
              factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
              integratedSecurity="false"
              serverName="127.0.0.1"
              databaseName="yourDbName"
              portNumber="1433"
              user="username"
              password="pwd" />

      

+1


source







All Articles