Hello all,

Has anyone addressed this?  I tried setting the pingQuery command to 'select
dummy from dual', but the GenericDataSource still did not pick up that the
connection it had was stale...

My solution is a work around.  I would have liked to continue using the
Struts connection pool, but it just did not work very well with frequently
dropping DB connections.

The connection it provides may be stale and invalid, but the URL, username,
and password are still good.  So in my code, I simply took those attributes
and used them in my own datasource.  I used Oracle's own pooled connection
datasource, it recovers fine from dropped DB connections.  With the new
datasource, I could again create reliable connections by taking connections
from the connection pool.

I understand this approach is not ideal, but in light of the
GenericDataSource not working in my situation, it is usable.

Anyone have a better solution?  

This is the code I used...

Action.java
.
.
.
javax.sql.DataSource dataSource = servlet.findDataSource("DB");
      GenericDataSource ds = (GenericDataSource) dataSource;
      model.setCon(ds.getUrl());

Model.java
.
.
.
  public void setCon(String url) throws SQLException{

      OracleDataSource ods = new OracleDataSource();

      // Set the user name, password, driver type and network protocol
      ods.setURL(url);

      // Retrieve a connection
      con = ods.getConnection();

      con.setAutoCommit(false);
  }

RE: DataSource timeouts?

----------------------------------------------------------------------------
----

From: VASQUEZ_JASON 
Subject: RE: DataSource timeouts? 
Date: Fri, 03 Aug 2001 04:58:56 -0700 

----------------------------------------------------------------------------
----

I understand that--my app does "close" connections (release back to the 
pool).  The problem is that the pool itself maintains open connections to 
the database, and doesn't seem to recover very well when the databsae dies 
and comes back.

-jason

[EMAIL PROTECTED]
08/02/2001 11:31 AM
Please respond to struts-user

 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        RE: DataSource timeouts?



in the documentation it says that you close the connection after you have
used it...
ie.
conn.close();
this wont close the connection but will release it for others to use...


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 5:07 PM
To: [EMAIL PROTECTED]
Subject: DataSource timeouts?


Is there any parameter that can be set to timeout datasources, or to 
re-init them after a specified period of time?  We recently bounced our 
Oracle database that our struts connection pool points to, and I noticed 
that all the connections had hung (the app just hung while trying to 
perform queries).  The only way to fix it (that I knew of) was to restart 
the servlet container.  Is there a better way around this?

Thnaks,
Jason

Reply via email to