问题描述
我一直在搜索与HikariCP(2.4.3),Spring(4.1.2)和MS SQL Server(2008)一起使用的JTDS(1.3.1)的配置,但是找不到完整且有效的示例.
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.
这就是我所拥有的:
<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>
任何人都可以共享生产环境中使用的JTDS配置吗?
Can anyone out there share the JTDS configs used in a production environment?
致谢.
更新
我发现了这样的帖子:
似乎JTDS在使用HikariCP时遇到问题.其实我也有这个问题.这是我对JTDS的完整配置:
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>
这正是我发布问题的原因,我希望看到一个完整的示例.但是,在HikariCP的页面上,JTDS被列为受支持的.我很困惑.
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.
推荐答案
以下作品:
<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>
请注意,此属性是必需的,因此Hikari不会假定驱动程序符合JDBC4(jTDS为3.0).
Notice the connectionTestQuery
property which is required so Hikari will not assume the driver is JDBC4 compliant (jTDS is 3.0 compliant).
这篇关于与HikariCP + Spring + MS SQL Server一起使用的JTDS的配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!