From: Anthony B. <ant...@ir...> - 2009-08-28 14:38:15
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body bgcolor="#ffffff" text="#000000"> Hi!<br> We've had a problem using MySQL database for storing opal2 jobs data instead of the default HSQLDB.<br> It turned out it was a timeout problem which is quite well described at the following address: <a class="moz-txt-link-freetext" href="http://www.databasesandlife.com/automatic-reconnect-from-hibernate-to-mysql/">http://www.databasesandlife.com/automatic-reconnect-from-hibernate-to-mysql/</a>. Briefly: mysql closes connection after an 8h timeout (which is quite frequent for us, but not for servers where there is more activity).<br> We solved it by using c3p0 to manage database connection.<br> Here is what we have done to use it:<br> <br> -Added c3p0 package in $opal_sources/lib/ and modified build.xml consequently<br> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css"> <!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --></style> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css"> <!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --></style>-Created $opal_sources /etc/c3p0.properties and added " c3p0.preferredTestQuery=SELECT 1; " in it.<br> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css">!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --></style> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css"> <!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } --></style>-In build.xml, after <include name="OpalState.hbm.xml"/> added <include name="c3p0.properties"/><br> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css"> <!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -</style>-In $OPAL_SOURCES/etc/hibernate-opal.cfg.xml, replaced:<br> <br> <!-- JDBC connection pool (use the built-in) --><br> <!--<property name="connection.pool_size">1</property>--> <br> <br> By these lines:<br> <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"> <title></title> <meta name="GENERATOR" content="OpenOffice.org 3.0 (Linux)"> <style type="text/css"> <!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } -cd</style><br> <!-- JDBC connection pool (use c3p0) --><br> <property name="c3p0.min_size">1</property><br> <property name="c3p0.max_size">20</property><br> <property name="c3p0.timeout">1800</property><br> <property name="c3p0.max_statements">50</property><br> <property name="c3p0.idle_test_period">1800</property><br> <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><br> <br> Maybe it would be a good idea to include it in a future version of opal?<br> Bye!<br> <br> </body> </html> |