Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat8 loading wrong SQL Server Driver / SQLServerXADataSource not found

I'm trying to set up a connection pool using com.microsoft.sqlserver.jdbc.SQLServerXADataSourcein Tomcat8. While everything is fine using com.microsoft.sqlserver.jdbc.SQLServerDriver, when using SQLServerXADataSource, Tomcat claims No suitable driver found.

I'm sure that the correct driver jar is in $CATALINA\lib, however I am not sure if it is loaded correctly, as com.microsoft.sqlserver.jdbc.SQLServerDriver is working with and without that driver in lib. Maybe there is some other driver loaded which I could not locate.

Similar problem on Windows and OS X so far...

Does anyone know how to solve this?

UPDATE: Im setting up my datasource in-Code, like this:

//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);
like image 287
gapvision Avatar asked May 20 '26 14:05

gapvision


1 Answers

This configuration should work. Make the necessary changes for 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" />
like image 112
zulqarnain Avatar answered May 22 '26 04:05

zulqarnain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!