I kept googling for configuration of JTDS (1.3.1) for use with HikariCP (2.4.3), Spring (4.1.2), and MS SQL Server (2008), but unable to find a complete and working example.
Here is what I have:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceClassName" value="${jdbc.dataSourceClassName}" />
<property name="maximumPoolSize" value="${jdbc.maximumPoolSize}" />
<property name="minimumIdle" value="${jdbc.minimumIdle}" />
<property name="idleTimeout" value="${jdbc.idleTimeout}" />
....
<property name="dataSourceProperties">
<props>
....
</props>
</property>
</bean>
Can anyone out there share the JTDS configs used in a production environment?
Regards.
UPDATE
I found this SO post:
HikariCP hanging on getConnection
It seems that JTDS has a problem working with HikariCP. Actually, I have this problem too. Here is my complete config for JTDS:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig" />
</bean>
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="poolName" value="springHikariCP" />
<property name="connectionTestQuery" value="${jdbc.connectionTestQuery}" />
<property name="dataSourceClassName" value="${jdbc.dataSourceClassName}" />
<property name="maximumPoolSize" value="${jdbc.maximumPoolSize}" />
<property name="minimumIdle" value="${jdbc.minimumIdle}" />
<property name="idleTimeout" value="${jdbc.idleTimeout}" />
<property name="connectionTimeout" value="${jdbc.connectionTimeout}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="dataSourceProperties">
<props>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
<prop key="cacheMetaData">${jtds.cacheMetaData}</prop>
</props>
</property>
</bean>
This is exactly the reason I posted my question, and I hope to see a complete example. However, at HikariCP's page, JTDS is listed as supported. I am confused.
For other drivers, see the list of supported drivers. Extract the ZIP file. Copy the jtds-x.x.x.jar file to the bin/ext folder of your ReadyAPI installation.
Configuring Hikari With Spring Boot 1. x uses the Tomcat JDBC Connection Pool by default. As soon as we include spring-boot-starter-data-jpa into our pom. xml, we'll transitively include a dependency to the Tomcat JDBC implementation. During runtime, Spring Boot will then create a Tomcat DataSource for us to use.
jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000, 2005, 2008 and 2012) and Sybase Adaptive Server Enterprise (10, 11, 12 and 15). jTDS is based on FreeTDS and is currently the fastest production-ready JDBC driver for SQL Server and Sybase ASE.
JDBC (Java Database Connectivity) is a programming interface that lets Java applications access a relational database. SuperCHANNEL needs a JDBC driver so that it can access the relational database system (e.g. SQL Server, Oracle, etc) where your source data is stored.
The following works:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close" depends-on="flyway">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="connectionTestQuery" value="SELECT GETDATE()"/>
<property name="maximumPoolSize" value="32"/>
<property name="jdbcUrl" value="${dbUrl}"/>
<property name="username" value="${dbUsername}"/>
<property name="password" value="${dbPassword}"/>
</bean>
Notice the connectionTestQuery
property which is required so Hikari will not assume the driver is JDBC4 compliant (jTDS is 3.0 compliant).
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