English 中文(简体)
MySQLLink Timeout Issue - Grails Application on Tomcat using Hibernate and ORM
原标题:MySQL Connection Timeout Issue - Grails Application on Tomcat using Hibernate and ORM

我在乌兰巴托的Tomcat有一小块铁路应用。 我将MySql用作我的数据库,除非我将申请时间超过半天(8个小时)否则,一切工作都会被罚款。 我进行了一些搜索,显然这是我的sql.cnf在8小时之后的默认(wait_timeout),但Tomcat在下一用户试图查看连接故障的地点时,会失去联系。 重新启用该网页将纠正这一错误,但我想完全消除这一错误。 我版本的MySql(5.75) 我只拿我的手法,它没有包含这样的参数,无论如何,改变这一参数并不能解决问题。

http://www.databasesandlife.com/automatic-relink- from-hibernate-to-mysql/"rel=“noreferer”>Blog Post似乎报告了一个类似的错误,但我仍然不完全理解我需要做些什么来召集这种固定,而且我希望,解决办法比另一个第三方图书馆简单。 机器一米的运行时间为256德国马克拉姆,Im试图将方案/服务数量保持在最低限度。

我是否可以在Grails /Tocat / MySql中召集一些事情,以摆脱这种状况?

提前感谢,

Gav

来自我的卡塔里纳特;

2010-04-29 21:26:25,946 [http-8080-2] ERROR util.JDBCExceptionReporter  - The last packet successfully received from the server was 102,906,722 milliseconds$
2010-04-29 21:26:25,994 [http-8080-2] ERROR errors.GrailsExceptionResolver  - Broken pipe
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
         ...
2010-04-29 21:26:26,016 [http-8080-2] ERROR util.JDBCExceptionReporter  - Already closed.
2010-04-29 21:26:26,016 [http-8080-2] ERROR util.JDBCExceptionReporter  - Already closed.
2010-04-29 21:26:26,017 [http-8080-2] ERROR servlet.GrailsDispatcherServlet  - HandlerInterceptor.afterCompletion threw exception
org.hibernate.exception.GenericJDBCException: Cannot release connection
        at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Already closed.
        at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:84)
        at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:181)
        ... 1 more
最佳回答

请注意article,你与行预科的联系人有固定的联系,但由职业顾问办公室或防火墙默射。

The solution is to define a validation query and do a sanity check of the connection before you actually use it in your application. In grails this is actually done by modifying the grails-app/conf/spring/Resource.groovy file and add the following:

beans = {
  dataSource(BasicDataSource) {
    //run the evictor every 30 minutes and evict any connections older than 30 minutes.
    minEvictableIdleTimeMillis=1800000
    timeBetweenEvictionRunsMillis=1800000
    numTestsPerEvictionRun=3
    //test the connection while its idle, before borrow and return it
    testOnBorrow=true
    testWhileIdle=true
    testOnReturn=true
    validationQuery="SELECT 1"
  }
} 
问题回答

在铁路1.3.X中,你可以修改数据来源中的电子轨迹值。 用于确保集合连接的农业档案在闲置期间使用。 这将确保我的服务器不会脱离连接。

production {
  dataSource {
    pooled = true
    // Other database parameters..
    properties {
       maxActive = 50
       maxIdle = 25
       minIdle = 5
       initialSize = 5
       minEvictableIdleTimeMillis = 1800000
       timeBetweenEvictionRunsMillis = 1800000
       maxWait = 10000
    }
}

快速核实这项工作的方法是修改MySQL我的组合文件[Msql]部分,增加低值的等候时间。

通过在你的数据库中增加开放的MySQL连接的数量。 groovy:

dataSource {
     driverClassName = "com.mysql.jdbc.Driver"
     pooled=true
     maxActive=10
     initialSize=5
     // Remaining connection params
}

如果你想走整个线,就尝试安装连接池;这里是

关于铁路1.3.X,我不得不在诱杀装置上添加以下代码。 groovy:

  def init = {servletContext ->
  def ctx=servletContext.getAttribute(ApplicationAttributes.APPLICATION_CONTEXT)

    //implement test on borrow
    def dataSource = ctx.dataSource
    dataSource.targetDataSource.setMinEvictableIdleTimeMillis(1000 * 60 * 30)
    dataSource.targetDataSource.setTimeBetweenEvictionRunsMillis(1000 * 60 * 30)
    dataSource.targetDataSource.setNumTestsPerEvictionRun(3)
    dataSource.targetDataSource.setTestOnBorrow(true)
    dataSource.targetDataSource.setTestWhileIdle(true)
    dataSource.targetDataSource.setTestOnReturn(false)
    dataSource.targetDataSource.setValidationQuery("SELECT 1")

  }

我还不得不进口org.codehaus.groovy.grails.commons.ApplicationAttributes

你们的亚行联系如何显示这种看法? 页: 1 页: 1

jdbc:mysql://hostname/mydb?autoReconnect=true




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签