本站首页    管理页面    写新日志    退出


«November 2025»
1
2345678
9101112131415
16171819202122
23242526272829
30


公告
暂无公告...

我的分类(专题)

日志更新

最新评论

留言板

链接


Blog信息
blog名称:
日志总数:15
评论数量:30
留言数量:0
访问次数:94758
建立时间:2006年4月26日




Mysql 的 java.io.EOFException
心得体会,  软件技术

NaddyLee 发表于 2006/9/27 12:56:02

数据库换用mysql后,jboss在每天早上都要重启,查看后台,错误如下:  com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1913)        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2304)        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2803)        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)        at com.mysql.jdbc.Connection.execSQL(Connection.java:3118)        at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:5215)        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkTransaction(BaseWrapperManagedConnection.java:425)        at org.jboss.resource.adapter.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:766)        at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:214)        at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497) ……  这个问题是由于连接池中的连接失效引起的。  在 MySQL 的默认设置中,空闲超过 8 小时的连接会被自动关闭(interactive_timeout=28800,wait_timeout=28800)。 当连接池没有销毁掉空闲时间超过设置的连接,这些连接会因为已被数据库关闭而导致失效。    在原来的数据库连接池设置中,idle-timeout-minutes 的值设置为0(不销毁空闲连接),因此出现了在每天早上(空闲超过 8 小时),连接失效的情况。      在 Tomcat 的 Realm 设置中,有时也会出现这种情况(Realm 中没有设置 idle-timeout)。解决的方法是升级到 Tomcat 5.5.9 以上版本,并将 JDBCRealm 改为 DataSourceRealm。        还有一种情况 http://bugs.mysql.com/bug.php?id=14279 是在使用 XAConnections 的时候出现。是因为 mysql 的 JDBC 驱动在清理连接时,没有检查是否 XA 的 connection 就直接调用 rollback 引起的。出现这个问题的驱动是:mysql-connector-java-5.0-nightly-2005102。这个缺陷报告的状态已被设为关闭(已修复?)。


阅读全文(9286) | 回复(1) | 编辑 | 精华
 


回复:Mysql 的 java.io.EOFException
心得体会,  软件技术

dada(游客)发表评论于2009/12/31 15:50:50

胜达峰业(北京)科技有限公司 对讲机 摩托罗拉对讲机 防爆对讲机 对讲机选购网 建伍对讲机 威泰克斯对讲机 艾可慕对讲机 防水对讲机 无线对讲机 walkie-talkie 摩托罗拉对讲机价格 摩托罗拉对讲机价格 摩托罗拉民用对讲机 摩托罗拉无线对讲机 摩托罗拉328对讲机 对讲机批发 摩托罗拉无线对讲机 品牌对讲机 防爆对讲机 摩托罗拉GP328防爆对讲机


个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除
 


回复:Mysql 的 java.io.EOFException
心得体会,  软件技术

飞(游客)发表评论于2006/10/20 11:29:23

NaddyLee , 你好, 请问你现在解决了这个问题么? 我这几天也遭遇了这个问题, 我使用的是tomcat 服务器, 连接池是DBCP, 请问你是如何解决的? 因为我在查看tomcat的server.xml配置中, 并没有发现如何设置idle_timeout啊? 很急, 请和我交流,非常感谢:) 以下为blog主人的回复:     不好意思,这几天都没上来看。    我是在jboss3.2.5上做这个设置的,到目前为止,没有问题。    在Tomcat上的设置,不知道你用的是哪个版本,我在5.5的文档中找到的设置如下:<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true"> <!-- maxActive: Maximum number of dB connections in pool. Make sure you configure your mysqld max_connections large enough to handle all of your db connections. Set to 0 for no limit. --> <!-- maxIdle: Maximum number of idle dB connections to retain in pool. Set to -1 for no limit. See also the DBCP documentation on this and the minEvictableIdleTimeMillis configuration parameter. --> <!-- maxWait: Maximum time to wait for a dB connection to become available in ms, in this example 10 seconds. An Exception is thrown if this timeout is exceeded. Set to -1 to wait indefinitely. --> <!-- username and password: MySQL dB username and password for dB connections --> <!-- driverClassName: Class name for the old mm.mysql JDBC driver is org.gjt.mm.mysql.Driver - we recommend using Connector/J though. Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver. --> <!-- url: The JDBC connection url for connecting to your MySQL dB. The autoReconnect=true argument to the url makes sure that the mm.mysql JDBC Driver will automatically reconnect if mysqld closed the connection. mysqld by default closes idle connections after 8 hours. --> <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="javauser" password="javadude" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/> </Context>在DBCP的配置说明中http://jakarta.apache.org/commons/dbcp/configuration.html,有以下部分: ParameterDefaultDescriptionvalidationQueryThe SQL query that will be used to validate connections from this pool before returning them to the caller. If specified, this query MUST be an SQL SELECT statement that returns at least one row. testOnBorrowtrueThe indication of whether objects will be validated before being borrowed from the pool. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. testOnReturnfalseThe indication of whether objects will be validated before being returned to the pool. NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. testWhileIdlefalseThe indication of whether objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool. NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string. timeBetweenEvictionRunsMillis-1The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run. numTestsPerEvictionRun3The number of objects to examine during each run of the idle object evictor thread (if any). minEvictableIdleTimeMillis1000 * 60 * 30The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).

个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除
 


» 1 »

发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 2.906 second(s), page refreshed 144801079 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号