默认连接池无法正常工作

时间:2015-01-18 15:23:58

标签: hibernate spring-boot

我在stackoverflow上看到了一些类似的问题,但没有一个有帮助。所以我走了。

我正在使用以下库

  • Spring Boot 1.2.0
  • Spring Data JPA
  • Hibernate 4.3.7
  • Tomcat JDBC 8.015
  • MySql Connector 5.1.34

poolProperties method中检查tomcat.jdbc.pool.DatasourceProxy::createPool()时,我得到以下内容

ConnectionPool[defaultAutoCommit=null; defaultReadOnly=null; defaultTransactionIsolation=-1; defaultCatalog=null; driverClassName=com.mysql.jdbc.Driver; maxActive=100; maxIdle=100; minIdle=10; initialSize=10; maxWait=30000; testOnBorrow=false; testOnReturn=false; timeBetweenEvictionRunsMillis=5000; numTestsPerEvictionRun=0; minEvictableIdleTimeMillis=60000; testWhileIdle=false; testOnConnect=false; password=********; url=jdbc:mysql://localhost/test; username=test; validationQuery=null; validationQueryTimeout=-1; validatorClassName=null; validationInterval=30000; accessToUnderlyingConnectionAllowed=true; removeAbandoned=false; removeAbandonedTimeout=60; logAbandoned=false; connectionProperties=null; initSQL=null; jdbcInterceptors=null; jmxEnabled=true; fairQueue=true; useEquals=true; abandonWhenPercentageFull=0; maxAge=0; useLock=false; dataSource=null; dataSourceJNDI=null; suspectTimeout=0; alternateUsernameAllowed=false; commitOnReturn=false; rollbackOnReturn=false; useDisposableConnectionFacade=true; logValidationErrors=false; propagateInterruptState=false; ignoreExceptionOnPreLoad=false; 

然而,我得到java.net.SocketException:每天早上破管。我的配置有什么问题吗?我不是在创建一个DataSource。根据{{​​3}},一切都应该自动配置。

更新:我得到的例外与documentation问题完全相似。在该问题中,建议使用池化机制。我正在使用数据源池我仍然遇到问题

1 个答案:

答案 0 :(得分:1)

它可能无法解决您的具体问题(很难确定您提供的信息)但我建议您配置适合MySQL的验证查询并启用testOnBorrow或类似问题。