You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Richards <gr...@cyber4.org> on 2001/03/07 13:55:19 UTC

Database pooling code

Has anyone got the database pooling code/DataSource to work or specifically
had it fail?

I've been having problems (documented previously) and I've read about a few others
who can't seem to get the pooling to work as well, and I want to get an idea
of specifically where the problem might lie in order to fix it.




----
You are the simulacrum of my dreams
 and the signifier of my desires

Mr Grumpy ... come and visit his home!
	http://www.cyber4.org/members/grumpy/index.html

Re: Database pooling code

Posted by Ted Husted <ne...@husted.com>.
Work is under way on a database connection pool that can be used by
Struts and other Jakarta products. 

The codebase includes several requested features, including monitoring
expired connections. 

For a few additional details, see <
http://www.webappcabaret.com/rwald/dbcp/ >. 

Rodney Waldhoff is working on this with Geir Magnusson, of Velocity, and
several committers from other projects, including, or course, The Craig.

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/commons

Jim Richards wrote:
> 
> Has anyone got the database pooling code/DataSource to work or specifically
> had it fail?
> 
> I've been having problems (documented previously) and I've read about a few others
> who can't seem to get the pooling to work as well, and I want to get an idea
> of specifically where the problem might lie in order to fix it.

Re: Forbidden: you don't have permission...

Posted by Maya Muchnik <mm...@pumatech.com>.
It is my guess. Because your Tomcat installation is done in other computer
you do not know what permission are at Tomcat working directory
(tomcat/dist/tomcat/work) where the jasper compiler will put your "java"
and "class" files for your servlets - jsp files. Check permissions there
and other directories under Tomcat (webapps,...). And the top directory
tomcat/dist/tomcat.
Maya

"Horace A. Vallas, Jr." wrote:

> when I start things up, it looks like it loads ok but
> I'm working remotely and cannot seem to get to the struts-example
> across the net -- I get a response Forbidden, you don't have
> permission...
>
> the standard error_log says "client denied by server configuration:..."
>
> I'm running in a number virtual host - apache1.3.12 and tomcat 3.2.1
> with all the struts-required things like java2 etc.  and, again,
> it looks like the struts-example stuff unpacks and starts up ok when
> I start tomcat.
>
> tomcat and the virtual host are, of course, rooted differently
>
> jsp and my own servlets are working fine, though my servlets are
> basically rooted with the virtual host (/WEB-INF/classes at the
> virtual host's root)
>
> Any pointers on how I can reach it from the net?
>
> --
> Wishing you an "OOBA OOBA" 21st Century!!
> Horace                            ...once known as "Kicker" :-)
> ================================================================
> Horace Vallas   hav.Software                 http://www.hav.com/
>                 P.O. Box 354                         hav@hav.com
>                 Richmond, Tx. 77406-0354     voice: 281-341-5035
>                 USA                            fax: 281-341-5087
>
> Thawte Web Of Trust Notary in SW Houston, Tx.
> http://www.hav.com/?content=/thawteWOTnotary.htm
> ================================================================
> ...drop by and chat if I'm online       http://www.hav.com/chat/
> ===   ===   ===   ===   ===   ===   ===   ===   ===   ===   ====
> What is a Vet? ... He is the barroom loudmouth, dumber than five
> wooden planks, whose overgrown frat-boy behavior is outweighed a
> hundred times in the cosmic scales by four hours of exquisite
> bravery near the 38th parallel. ...   - Unknown
> ================================================================


Forbidden: you don't have permission...

Posted by "Horace A. Vallas, Jr." <ha...@hav.com>.
when I start things up, it looks like it loads ok but
I'm working remotely and cannot seem to get to the struts-example
across the net -- I get a response Forbidden, you don't have permission...

the standard error_log says "client denied by server configuration:..."

I'm running in a number virtual host - apache1.3.12 and tomcat 3.2.1
with all the struts-required things like java2 etc.  and, again,
it looks like the struts-example stuff unpacks and starts up ok when
I start tomcat.

tomcat and the virtual host are, of course, rooted differently

jsp and my own servlets are working fine, though my servlets are
basically rooted with the virtual host (/WEB-INF/classes at the
virtual host's root)

Any pointers on how I can reach it from the net?

-- 
Wishing you an "OOBA OOBA" 21st Century!!
Horace                            ...once known as "Kicker" :-)  
================================================================
Horace Vallas   hav.Software                 http://www.hav.com/     
                P.O. Box 354                         hav@hav.com
                Richmond, Tx. 77406-0354     voice: 281-341-5035 
                USA                            fax: 281-341-5087

Thawte Web Of Trust Notary in SW Houston, Tx.
http://www.hav.com/?content=/thawteWOTnotary.htm
================================================================
...drop by and chat if I'm online       http://www.hav.com/chat/
===   ===   ===   ===   ===   ===   ===   ===   ===   ===   ====
What is a Vet? ... He is the barroom loudmouth, dumber than five 
wooden planks, whose overgrown frat-boy behavior is outweighed a 
hundred times in the cosmic scales by four hours of exquisite 
bravery near the 38th parallel. ...   - Unknown
================================================================

Re: Database pooling code

Posted by Matthias Bauer <Ma...@livinglogic.de>.
Here you go (file
postgresql-7.0.3/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java):

>   /**
>    * Tests to see if a Connection is closed
>    *
>    * @return the status of the connection
>    * @exception SQLException (why?)
>    */
>   public boolean isClosed() throws SQLException
>   {
>     //return (pg_stream == null);
>     if(pg_stream == null)
>       return true;
>     // ok, test the connection
>     try {
>       // by sending an empty query. If we are dead, then an SQLException should
>       // be thrown
>       java.sql.ResultSet rs = ExecSQL(" ");
>       if(rs!=null)
>         rs.close();
> 
>       // By now, we must be alive
>       return false;
>     } catch(SQLException se) {
>       // Why throw an SQLException as this may fail without throwing one,
>       // ie isClosed() is called incase the connection has died, and we don't
>       // want to find out by an Exception, so instead we return true, as its
>       // most likely why it was thrown in the first place.
>       return true;
>     }
>   }

--- Matthias

Ted Husted wrote:
> 
> Matthias Bauer wrote:
> > PostgresSQL didn't work, but we patched it
> 
> Can you share your patch?
> 
> -Ted.

Re: Database pooling code

Posted by Ted Husted <ne...@husted.com>.
Matthias Bauer wrote:
> PostgresSQL didn't work, but we patched it

Can you share your patch?

-Ted.

Re: Database pooling code

Posted by Matthias Bauer <Ma...@livinglogic.de>.
I am just testing the isClosed() method. In my opinion it is the driver's
responsibility to use the most efficient way to test if the connection is valid
or not. 

Testing with a simple statement like "select * from dual" is certainly also an
option, but definitely less efficient. Because normally this means parsing an
sql string, executing it and so on, whereas the driver can use some proprietary
method to ask the server if a connection is still valid. 

I tested the isClosed() method for the following drivers:

MySQL             worked
PostgresSQL       didn't work, but we patched it
InterClient 1.6   didn't work

--- Matthias



Johan Compagner wrote:
> 
> Do you just test the isClosed() method?
> My plan was to execute a small sql code that has a very little overhead
> and alway's returns normal for every db if the connection is still good.
> 
> But i don't know what kind of sql statement works for every db.
> 
> johan
> 
> > -----Original Message-----
> > From: hias@livinglogic.de [mailto:hias@livinglogic.de]On Behalf Of
> > Matthias Bauer
> > Sent: Wednesday, March 07, 2001 4:02 PM
> > To: struts-user@jakarta.apache.org
> > Subject: Re: Database pooling code
> >
> >
> > Database pooling works pretty well for me. But there are some
> > pitfalls, when a
> > connection times out or the database server is restarted. As the
> > framework does
> > not check if a connection is still valid before returning it to
> > the application
> > you will run into an exception when trying to use a connection
> > which has timed
> > out or was closed due to some other reason on the server side.
> >
> > I know there was some discussion going on about this on the list
> > in the past.
> > There were some pros and cons about whether the framework should check the
> > validity of a connection before returning it to the application.
> > I patched the
> > struts code in order to do this check and always return a valid connection
> > (requires the jdbc driver Connection.isClosed() method to work
> > correctly - some
> > have a bug in their implementation). If you are interested in
> > this little patch,
> > please let me know.
> >
> > --- Matthias
> >
> >
> > I patched
> >
> > Jim Richards wrote:
> > >
> > > Has anyone got the database pooling code/DataSource to work or
> > specifically
> > > had it fail?
> > >
> > > I've been having problems (documented previously) and I've read
> > about a few others
> > > who can't seem to get the pooling to work as well, and I want
> > to get an idea
> > > of specifically where the problem might lie in order to fix it.
> > >
> > > ----
> > > You are the simulacrum of my dreams
> > >  and the signifier of my desires
> > >
> > > Mr Grumpy ... come and visit his home!
> > >         http://www.cyber4.org/members/grumpy/index.html
> >

RE: Database pooling code

Posted by Johan Compagner <jc...@j-com.nl>.
Do you just test the isClosed() method?
My plan was to execute a small sql code that has a very little overhead
and alway's returns normal for every db if the connection is still good.

But i don't know what kind of sql statement works for every db.

johan


> -----Original Message-----
> From: hias@livinglogic.de [mailto:hias@livinglogic.de]On Behalf Of
> Matthias Bauer
> Sent: Wednesday, March 07, 2001 4:02 PM
> To: struts-user@jakarta.apache.org
> Subject: Re: Database pooling code
>
>
> Database pooling works pretty well for me. But there are some
> pitfalls, when a
> connection times out or the database server is restarted. As the
> framework does
> not check if a connection is still valid before returning it to
> the application
> you will run into an exception when trying to use a connection
> which has timed
> out or was closed due to some other reason on the server side.
>
> I know there was some discussion going on about this on the list
> in the past.
> There were some pros and cons about whether the framework should check the
> validity of a connection before returning it to the application.
> I patched the
> struts code in order to do this check and always return a valid connection
> (requires the jdbc driver Connection.isClosed() method to work
> correctly - some
> have a bug in their implementation). If you are interested in
> this little patch,
> please let me know.
>
> --- Matthias
>
>
> I patched
>
> Jim Richards wrote:
> >
> > Has anyone got the database pooling code/DataSource to work or
> specifically
> > had it fail?
> >
> > I've been having problems (documented previously) and I've read
> about a few others
> > who can't seem to get the pooling to work as well, and I want
> to get an idea
> > of specifically where the problem might lie in order to fix it.
> >
> > ----
> > You are the simulacrum of my dreams
> >  and the signifier of my desires
> >
> > Mr Grumpy ... come and visit his home!
> >         http://www.cyber4.org/members/grumpy/index.html
>


Re: Database pooling code

Posted by Matthias Bauer <Ma...@livinglogic.de>.
Database pooling works pretty well for me. But there are some pitfalls, when a
connection times out or the database server is restarted. As the framework does
not check if a connection is still valid before returning it to the application
you will run into an exception when trying to use a connection which has timed
out or was closed due to some other reason on the server side. 

I know there was some discussion going on about this on the list in the past.
There were some pros and cons about whether the framework should check the
validity of a connection before returning it to the application. I patched the
struts code in order to do this check and always return a valid connection
(requires the jdbc driver Connection.isClosed() method to work correctly - some
have a bug in their implementation). If you are interested in this little patch,
please let me know.

--- Matthias


I patched 

Jim Richards wrote:
> 
> Has anyone got the database pooling code/DataSource to work or specifically
> had it fail?
> 
> I've been having problems (documented previously) and I've read about a few others
> who can't seem to get the pooling to work as well, and I want to get an idea
> of specifically where the problem might lie in order to fix it.
> 
> ----
> You are the simulacrum of my dreams
>  and the signifier of my desires
> 
> Mr Grumpy ... come and visit his home!
>         http://www.cyber4.org/members/grumpy/index.html

Re: Database pooling code

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Wed, 7 Mar 2001, Jim Richards wrote:

> 
> Has anyone got the database pooling code/DataSource to work or specifically
> had it fail?
> 
> I've been having problems (documented previously) and I've read about a few others
> who can't seem to get the pooling to work as well, and I want to get an idea
> of specifically where the problem might lie in order to fix it.

 I'm using the database connection pool with Informix Dynamic Server v7.2 and 
it appears to be working well. I have noticed that if my network
connection goes down (I pull the plug on the network for a while), I need
to restart Tomcat to reinitialize the connection pool. If I only
momentarily pull the plug, the subsequent query takes longer to run, but
does so successfully.

 I admit, I have not looked into the details of all this. But if there is
a way to automate detection of an expired connection and tossing it,
or reinitializing the connection pool (if all the connections are bad),
I'd certainly be interested in having that capability either incorporated
into Struts or available as a patch. Thanks.