Hi, ... did not know that such an engine was available - will try it...
-----Ursprüngliche Nachricht----- Von: Ralf Joachim [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 21. Juni 2005 10:19 An: dev@castor.codehaus.org Betreff: Re: AW: [castor-dev] JDO / MySQL DB reconnect problem Hi Carell, why do you use generic engine? Wouldn't it be better to use mysql engine as per: <database name="sifs" engine="mysql" > Regards Ralf Werner Guttmann schrieb: > Carell, > > let me try to explain a couple of things. As layed out by your code > fragments below, Castor is configured to obtain a JDBC connection from > a java.sql.DataSource (instantiated through a JNDI lookup). In other > words, Castor per se cannot do anything about stale connections (and > actually is designed to do so), as connection handling is the sole > responsibility of the JDBC DataSource (or teh underlying JDBC > connection pool in your case). > > As you are using Jakara Common DBCP, have a look at > > http://jakarta.apache.org/commons/dbcp/configuration.html > > and you'll see various options (validationQuery, testOnBorrow, > testOnReturn) that allow you to configure DBCP (not Castor) how to > deal with stale connections. > > Having said that, please keep in mind that a possible source for the > problem you are seeing might be related to the way you seem to be > using Castor: > > db = jdo.getDatabase(); > .... > db.close(); > > I do hope that in reality you have proper exception handling in place, > by e.g. wrapping above code fragment in a try/catch/finally clause, > thus guaranteeing that the Database instance (and hence the undrlying > JDBC connection) will be closed (and thus the JDBC connection returned > to the pool). > > Regards > Werner > > wg> -----Original Message----- > wg> From: Carell, Michael [mailto:[EMAIL PROTECTED] > wg> Sent: Tuesday, June 21, 2005 9:11 AM > wg> To: dev@castor.codehaus.org > wg> Subject: AW: AW: [castor-dev] JDO / MySQL DB reconnect problem > wg> > wg> > wg> Hi, > wg> > wg> i will answer your questions but at first i want to come > wg> back to the original > wg> problem: > wg> > wg> The problem was that it is (as far as i know) not possible to get > wg> a really fresh connection from castor. My application detected the > wg> problem with the DB connection and tried to get a new/ fresh one. > wg> But JDO always returned > wg> the connection that procecced the errors. > wg> > wg> Now to your questions: > wg> > wg> My application does not keep the connection open. > wg> I use the following statement to get a DB connection and to > wg> close it. > wg> > wg> JDO2.loadConfiguration (jdoConf); > wg> JDO2 jdo = JDO2.createInstance( "sifs2" ); > wg> db = jdo.getDatabase(); > wg> .... > wg> db.close(); > wg> > wg> thats it. > wg> > wg> Reproduction should be easy. > wg> > wg> * Get a DB connection from JDO > wg> * Create object in DB > wg> * Wait 12 hours (do not end app) > wg> * Get again a DB connection > wg> * Try to create => ERROR > wg> > wg> > wg> The tomcat configuration looks like: > wg> ------------------------------------- > wg> <Resource name="jdbc/SIFS" auth="Container" > wg> type="javax.sql.DataSource"/> > wg> > wg> <ResourceParams name="jdbc/SIFS"> > wg> <parameter> > wg> <name>url</name> > wg> > wg> <value>jdbc:mysql://172.18.25.149:3306/sifs?autoReconnect=tr > wg> ue</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>username</name> > wg> <value>root</value> > wg> </parameter> > wg> <parameter> > wg> <name>password</name> > wg> <value>root</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>factory</name> > wg> > wg> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>maxActive</name> > wg> <value>100</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>maxIdle</name> > wg> <value>10</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>maxWait</name> > wg> <value>20000</value> > wg> </parameter> > wg> > wg> <parameter> > wg> <name>driverClassName</name> > wg> <value>org.gjt.mm.mysql.Driver</value> > wg> </parameter> > wg> > wg> </ResourceParams> > wg> > wg> Castor config: > wg> -------------------------------------------------- > wg> <database name="sifs" engine="generic" > > wg> > wg> <jndi name="java:comp/env/jdbc/SIFS" /> > wg> > wg> <mapping href="resources/mapping.xml" /> > wg> </database> > wg> > wg> > wg> -----Ursprüngliche Nachricht----- > wg> Von: Werner Guttmann [mailto:[EMAIL PROTECTED] > wg> Gesendet: Montag, 20. Juni 2005 20:24 > wg> An: dev@castor.codehaus.org > wg> Betreff: Re: AW: [castor-dev] JDO / MySQL DB reconnect problem > wg> > wg> > wg> Hi Carell, > wg> > wg> Carell, Michael wrote: > wg> > Hi, > wg> > > wg> > i really do not know what the MySQL Connector J does. > wg> MySQL Connector/J is a synonym for the JDBC driver for mySQL. > wg> > Fact is that > wg> > the application receives the following exception > wg> > > wg> > java.io.EOFException > wg> > at com.mysql.jdbc.MysqlIO.readFully > wg> I actually don't think that mySQL or Castor JDO is the > wg> problem. Let me ask you a couple of questions: > wg> > wg> a) why do you need to keep a connection open for more than 8 hours > wg> ? > wg> b) how have you configured your connection pool. In other > wg> words, can you please show me the tomcat configuration file > wg> (assuming that you configured the pool in your server.xml file). > wg> > > wg> > I already configured the Tomcat to use a pooled Datasource and i > wg> > gave a SQL statement to able the database check by tomcat. But > wg> > nothing really helps. If i tried to create an object it failed. > wg> > > wg> > To get more information someone must debug / dig into the Tomcat > wg> > / ConnectorJ code. > wg> > > wg> > Thanks for your statement > wg> > Michael Carell > wg> > > wg> > -----Ursprüngliche Nachricht----- > wg> > Von: Stein M. Hugubakken [mailto:[EMAIL PROTECTED] > wg> > Gesendet: Freitag, 17. Juni 2005 12:24 > wg> > An: dev@castor.codehaus.org > wg> > Betreff: Re: [castor-dev] JDO / MySQL DB reconnect problem > wg> > > wg> > > wg> > Carell, Michael wrote: > wg> > > wg> >>Hi again, > wg> >> > wg> >>perhaps you remember my email from some days before. I have had > wg> >>a problem with the MySQL DB and a timeout on the DB connection. > wg> >> > wg> >>After some investigations i found the source of the problem. > wg> >>MySQL disconnects idle connections after some time (may be 8 > wg> >>hours). > wg> >> > wg> > > wg> > > wg> > Why have a connection open for 8 hours, shouldn't it be > wg> the job for a > wg> > connection-pool to give you an open connection? > wg> > > wg> > Stein > wg> > > wg> > ------------------------------------------------- > wg> > If you wish to unsubscribe from this list, please > wg> > send an empty message to the following address: > wg> > > wg> > [EMAIL PROTECTED] > wg> > ------------------------------------------------- > wg> > > wg> > ------------------------------------------------- > wg> > If you wish to unsubscribe from this list, please > wg> > send an empty message to the following address: > wg> > > wg> > [EMAIL PROTECTED] > wg> > ------------------------------------------------- > wg> > > wg> > > wg> > wg> > wg> ------------------------------------------------- > wg> If you wish to unsubscribe from this list, please > wg> send an empty message to the following address: > wg> > wg> [EMAIL PROTECTED] > wg> ------------------------------------------------- > wg> > wg> ------------------------------------------------- > wg> If you wish to unsubscribe from this list, please > wg> send an empty message to the following address: > wg> > wg> [EMAIL PROTECTED] > wg> ------------------------------------------------- > wg> > wg> > > ------------------------------------------------- > If you wish to unsubscribe from this list, please > send an empty message to the following address: > > [EMAIL PROTECTED] > ------------------------------------------------- -- Syscon Ingenieurbüro für Meß- und Datentechnik GmbH Ralf Joachim Raiffeisenstraße 11 D-72127 Kusterdingen Germany Tel. +49 7071 3690 52 Mobil: +49 173 9630135 Fax +49 7071 3690 98 Email: [EMAIL PROTECTED] Web: www.syscon-world.de ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] ------------------------------------------------- ------------------------------------------------- If you wish to unsubscribe from this list, please send an empty message to the following address: [EMAIL PROTECTED] -------------------------------------------------