从2.1升级到Grails 2.4.3我们似乎遇到了与MySQL数据库超时的JDBC连接问题?我跟随了一些在线指南,但很挣扎。
在我的数据源中我有:
test {
dataSource {
pooled = true
dbCreate = "update"
url = "jdbc:mysql://MYURL"
dialect = org.hibernate.dialect.MySQL5InnoDBDialect
driverClassName = "com.mysql.jdbc.Driver"
username = "username"
password = "password"
properties {
// Documentation for Tomcat JDBC Pool
// http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#Common_Attributes
// https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/tomcat/jdbc/pool/PoolConfiguration.html
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
ignoreExceptionOnPreLoad = true
// http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#JDBC_interceptors
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED // safe default
// controls for leaked connections
abandonWhenPercentageFull = 100 // settings are active only when pool is full
removeAbandonedTimeout = 120
removeAbandoned = true
// use JMX console to change this setting at runtime
logAbandoned = false // causes stacktrace recording overhead, use only for debugging
// JDBC driver properties
// Mysql as example
dbProperties {
// Mysql specific driver properties
// http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html
// let Tomcat JDBC Pool handle reconnecting
autoReconnect = false
// truncation behaviour
jdbcCompliantTruncation = false
// mysql 0-date conversion
zeroDateTimeBehavior = 'convertToNull'
// Tomcat JDBC Pool's StatementCache is used instead, so disable mysql driver's cache
cachePrepStmts = false
cacheCallableStmts = false
// Tomcat JDBC Pool's StatementFinalizer keeps track
dontTrackOpenResources = true
// performance optimization: reduce number of SQLExceptions thrown in mysql driver code
holdResultsOpenOverStatementClose = true
// enable MySQL query cache - using server prep stmts will disable query caching
useServerPrepStmts = false
// metadata caching
cacheServerConfiguration = true
cacheResultSetMetadata = true
metadataCacheSize = 100
// timeouts for TCP/IP
connectTimeout = 15000
socketTimeout = 120000
// timer tuning (disable)
maintainTimeStats = false
enableQueryTimeouts = false
// misc tuning
noDatetimeStringSync = true
}
}
}
}
我正在使用SpringSecurity Core Plugin和Spring Security UI ...在用户登录然后超时后,我收到错误,告诉用户他们的帐户已过期。在我添加Grails文档中建议的dbProperties配置之前,我会收到以下JDBC错误:
[http-8080-6] ERROR util.JDBCExceptionReporter - 连接关闭后不允许任何操作。驱动程序隐式关闭了连接。
[http-8080-6] ERROR transaction.JDBCTransaction - 无法切换自动提交 com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:连接关闭后不允许任何操作。驱动程序隐式关闭了连接。
无法读取服务器的响应。预计读取4个字节,在连接意外丢失之前读取0个字节.Stacktrace如下: java.io.EOFException:无法读取服务器的响应。预计读取4个字节,在连接意外丢失之前读取0个字节。
答案 0 :(得分:0)
谢谢Burt ......经过一番调查后,密码过期的问题对我来说看起来很奇怪...不确定它是否是你错过的东西?
如果用户将Password Expired标志设置为true,则可以重置其密码。然后,用户将完成输入用户名并获取通过电子邮件发送的重置密码链接的过程。在此链接并输入新密码后,用户将登录系统,但密码过期标志永远不会设置为true ...在帐户注销或超时后,用户无法重新启动,直到重置为止密码再次。所以有一个缺陷是用户在重置密码后可以留在系统内,或者在密码更改成功后应该设置标志,这样用户就不会被迫不断重置或与管理员交谈?
JDBC错误与上面的代码一起正常工作,但我同意并非所有变量都是必需的。