我有一个 Spring Java Web 应用程序。我正在尝试使用 Hikaricp 2.2.5 进行具有以下配置的连接池。
马文:
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
<version>2.2.5</version>
<scope>compile</scope>
</dependency>
XML:
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="minimumIdle" value="5"/>
<property name="maximumPoolSize" value="200"/>
<property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
<property name="connectionTestQuery" value="SELECT 1"/>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/app"/>
<property name="autoCommit" value="true"/>
<property name="connectionTimeout" value="30000"/>
<property name="idleTimeout" value="600000"/>
<property name="maxLifetime" value="1800000"/>
<property name="poolName" value="LoginPool"/>
</bean>
我收到以下错误NoSuchMethodError
。
异常堆栈跟踪:
Caused by: java.lang.NoSuchMethodError: java.sql.Connection.getNetworkTimeout()I
at com.zaxxer.hikari.util.PoolUtilities.isJdbc41Compliant(PoolUtilities.java:245)
at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:412)
at com.zaxxer.hikari.pool.HikariPool.fillPool(HikariPool.java:500)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:159)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:110)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:102)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:860)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:779)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1419)
... 109 more
如何解决问题?