Hi again, ----- Original Message ----- From: "John Holman" <[EMAIL PROTECTED]> To: "OJB Users List" <[EMAIL PROTECTED]> Sent: Wednesday, December 04, 2002 2:56 PM Subject: Re: OJB not robust against database or network failures
> Hi Armin > > > Yes, you are right I checked in this version a few days ago. I'm not a > > DB-expert, > > so I don't now what's the best solution to get the 'validationQuery' > > from. > > 1. Use a hard-coded query from the Platform implementation class > > 2. Allow user to set the query within the jdbc-connection-descriptor > > in the repository file. > > > > I'm not an expert either! But perhaps a hard coded default query from > Platform which can be overridden by the user by a validationQuery > attribute in jdbc-connection-descriptor or connection-pool? Thanks, attribute in connection-pool seems to be a good solution, because we only need this feature when using pooled connectins. If not set we only do a isClosed() validation. > > In the meantime is there a way of getting hold of the > PoolableConnectionFactory and setting the validation query directly in > the application? Should be possible. Extend ConnectionFactoryConPooledImpl.java and override #createObjectFactory. Then you could use your own implementation of BasePoolableObjectFactory. See source code for more detail. Change OJB.properties to use your own ConnectionFactory implementation. regards, Armin > > Thanks, John > > > Armin Waibel wrote: > > Hi John, > > > > > > ----- Original Message ----- > > From: "John Holman" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, December 04, 2002 2:23 PM > > Subject: OJB not robust against database or network failures > > > > > > > >>If the database or network goes down when OJB already has connections > > > > in > > > >>the underlying pool, I've found that OJB does not recover when the > >>database comes back up. I think this is because after an operation > > > > fails > > > >>the invalid connection is returned to the pool rather than being > >>destroyed and a new one created. > >> > >>Using the built-in connection pool ConnectionFactoryConPooledImpl I > >>tried setting "testOnBorrow" to true in the connection-pool element of > >>jdbc-connection-descriptor, but this did not help. Looking at the > > > > code, > > > >>ConnectionFactoryConPooledImpl.validateObject() just calls > >>java.sql.Connection.isClosed(), and this does not seem to detect that > >>the connection is invalid, at least for the JDBC drivers for > > > > Postgresql > > > >>and Oracle that I'm using. > >> > >>Then, I noticed that the current CVS version (0.9.8) offers a > >>ConnectionFactoryDBCPImpl option in OJB.properties. Using the Jakarta > >>DBCP connection pool directly in another application, I've found that > >>you can get robust behaviour by setting testOnBorrow to true and > > > > setting > > > >>a suitable validation query (e.g. select 0 from dual for Oracle). > >>However, it seems that OJB sets the validation query to null. (A > > > > comment > > > >>suggests this is because a suitable validation query would vary > > > > between > > > >>database platforms). And there does not seem to be a configuration > >>option to set/override the validation query ... > > > > > > Yes, you are right I checked in this version a few days ago. I'm not a > > DB-expert, > > so I don't now what's the best solution to get the 'validationQuery' > > from. > > 1. Use a hard-coded query from the Platform implementation class > > 2. Allow user to set the query within the jdbc-connection-descriptor > > in the repository file. > > > > Any comments welcome. > > > > regards, > > Armin > > > > > >>I'd be grateful for any suggestions. > >> > >>John. > >> > >> > >>-- > >>To unsubscribe, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > >>For additional commands, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > >> > >> > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
