You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Ronan-Yann Lorin <ro...@lorin.nom.fr> on 2001/12/30 12:28:04 UTC

JdbcDataSource pool

Hi,

I'm new to Avalon/Exvalibur and manage to use it in a new project. It will
be a Java server side application running in a servlet container. My first
need is to have a connection pooling package (and a server framework).
Avalon looks interesting for this duty.

I tried the datasource package (which I like for it's xml configuration
file). It gives me very poor performances with my JSP test page. I suspect
it's because of the datasource component opening/closing JDBC connections
and not working as a classical connection pool (get/release).

What would be the right solution?

Thanks in advance for your help.

Ronan-Yann Lorin  tél: +33 610 927 199
3, Allée des Hirondelles tél: +33 134 506 034
95220 Herblay   mailto:ronan-yann@lorin.nom.fr
France    http://lorin.nom.fr


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JdbcDataSource pool

Posted by Leif Mortenson <le...@silveregg.co.jp>.
Ronan,
	Late reply, but I just noticed this thread.  Did you ever get this 
problem resolved?  I ask because this last piece of advice was mistaken 
:-).  The JdbcConnections returned from Excalibur's pools are returned 
to the pool by calling their close method.  This was done to simplify 
their use.  So your code below looked correct in that respect.

	If you want to verify that the connections are really being recycled by 
the pool, try turning on debug logging for the connection pool.  That 
will show you that the connections are being added and removed from the 
pool as well as when new connections are being made.

	There was a bug in versions of excalibur towards the end of the year 
where the pool was not pooling the last poolable.  If the pool was 
suppoed to contain 5 poolables, it was closing 1 and only keeping 4.  If 
you only had one connection, it was being closed and reopened every 
time.  That may have been the cause of your speed problems.

	I also saw that you are using a custom DataSourceComponentSelector.  What 
the reason for doing this?

	Can you give your code a try with the latest CVS version of excalibur?

Cheers,
Leif


	

Alex Vishnev wrote:

> It looks like you are closing your connection yourself. Why? Look at the
> last statement of the attached source code. BTW,  do you call this piece of
> code every time, (i.e establishing Jdbc connection every time) or you are
> setting up your Jdbc connection once during your initialization?
> 
> Alex
> 
> -----Original Message-----
> From: Ronan-Yann Lorin [mailto:ronan-yann@lorin.nom.fr]
> Sent: Sunday, January 13, 2002 10:09 AM
> To: Avalon Developers List
> Subject: Re: JdbcDataSource pool
> 
> Thanks for your help.
> 
> I set up data source at startup in with the following lines:
>  public DataSourceComponent  scoringDataSource = null;
>   ComponentSelector dbSelector =
> (ComponentSelector)_excalibur.lookup("com.banqueagf.business.server.DataSour
> ceComponentSelector");
>   scoringDataSource = (DataSourceComponent)dbSelector.select("scoring");
> Sorry, I forgot the datasource config at office. I connect to an Oracle
> database.
> 
> I use the connection in a servlet service routine:
>   Connection  con;
> 
>   con = Server.getServer().scoringDataSource.getConnection();
>   PreparedStatement  stmt = con.prepareStatement("SELECT agf, sofinco,
> inconnu, habit FROM transc WHERE agf = ?");
>   stmt.setString(1, matricule.toUpperCase());
>                 ResultSet rs = stmt.executeQuery();
>          if (rs.next()) {
>    if (rs.getString("habit").compareTo("O") == 0) {
>     allowed = true;
>    } else {
>     allowed = false;
>    }
>    result = new LoanHabilitationData(rs.getString("agf"),
> rs.getString("sofinco"), allowed);
>   } else {
>    result = null;
>   }
>   rs.close();
> 
>   con.close();
> 
> When I make multiple calls, I get 5 times better response time with Turbine.
> So I guess this is because the connection is opened/closes at each call.
> 
> Regards
> Ronan-Yann Lorin                tél: +33 610 927 199
> 3, Allée des Hirondelles        tél: +33 134 506 034
> 95220 Herblay                   mailto:ronan-yann@lorin.nom.fr
> France                          http://lorin.nom.fr
> ----- Message d'origine -----
> De : "Berin Loritsch" <bl...@apache.org>
> À : "Avalon Developers List" <av...@jakarta.apache.org>
> Envoyé : lundi 31 décembre 2001 14:40
> Objet : Re: JdbcDataSource pool
> 
> 
> 
>>Ronan-Yann Lorin wrote:
>>
>>
>>>Hi,
>>>
>>>I'm new to Avalon/Exvalibur and manage to use it in a new project. It
>>>
> will
> 
>>>be a Java server side application running in a servlet container. My
>>>
> first
> 
>>>need is to have a connection pooling package (and a server framework).
>>>Avalon looks interesting for this duty.
>>>
>>>I tried the datasource package (which I like for it's xml configuration
>>>file). It gives me very poor performances with my JSP test page. I
>>>
> suspect
> 
>>>it's because of the datasource component opening/closing JDBC
>>>
> connections
> 
>>>and not working as a classical connection pool (get/release).
>>>
>>>What would be the right solution?
>>>
>>
>>There can be a number of reasons for this.  I was in the midst of making
>>
> fixes,
> 
>>but am officially out of time (my boss read me the riot act).
>>
>>Can you tell me exactly what your issues are?
>>
>>How are you setting up the Connection Pool?
>>
>>Are you instantiating a new pool on every request?  If so, no wonder!
>>Please post some more specifics regarding how you are using it in your
>>
> system.
> 
>>You can hide the actual queries and change the connection info when you
>>
> post.
> 
>>I am concerned with methodology--it could be something you are not doing
>>
> right.
> 
>>
>>>Thanks in advance for your help.
>>>
>>>Ronan-Yann Lorin  tél: +33 610 927 199
>>>3, Allée des Hirondelles tél: +33 134 506 034
>>>95220 Herblay   mailto:ronan-yann@lorin.nom.fr
>>>France    http://lorin.nom.fr
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>>
> <ma...@jakarta.apache.org>
> 
>>>For additional commands, e-mail:
>>>
> <ma...@jakarta.apache.org>
> 
>>>.
>>>
>>>
>>>
>>
>>
>>--
>>
>>"They that give up essential liberty to obtain a little temporary safety
>>  deserve neither liberty nor safety."
>>                 - Benjamin Franklin
>>
>>
>>--
>>To unsubscribe, e-mail:
>>
> <ma...@jakarta.apache.org>
> 
>>For additional commands, e-mail:
>>
> <ma...@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: JdbcDataSource pool

Posted by Alex Vishnev <av...@optonline.net>.
It looks like you are closing your connection yourself. Why? Look at the
last statement of the attached source code. BTW,  do you call this piece of
code every time, (i.e establishing Jdbc connection every time) or you are
setting up your Jdbc connection once during your initialization?

Alex

-----Original Message-----
From: Ronan-Yann Lorin [mailto:ronan-yann@lorin.nom.fr]
Sent: Sunday, January 13, 2002 10:09 AM
To: Avalon Developers List
Subject: Re: JdbcDataSource pool

Thanks for your help.

I set up data source at startup in with the following lines:
 public DataSourceComponent  scoringDataSource = null;
  ComponentSelector dbSelector =
(ComponentSelector)_excalibur.lookup("com.banqueagf.business.server.DataSour
ceComponentSelector");
  scoringDataSource = (DataSourceComponent)dbSelector.select("scoring");
Sorry, I forgot the datasource config at office. I connect to an Oracle
database.

I use the connection in a servlet service routine:
  Connection  con;

  con = Server.getServer().scoringDataSource.getConnection();
  PreparedStatement  stmt = con.prepareStatement("SELECT agf, sofinco,
inconnu, habit FROM transc WHERE agf = ?");
  stmt.setString(1, matricule.toUpperCase());
                ResultSet rs = stmt.executeQuery();
         if (rs.next()) {
   if (rs.getString("habit").compareTo("O") == 0) {
    allowed = true;
   } else {
    allowed = false;
   }
   result = new LoanHabilitationData(rs.getString("agf"),
rs.getString("sofinco"), allowed);
  } else {
   result = null;
  }
  rs.close();

  con.close();

When I make multiple calls, I get 5 times better response time with Turbine.
So I guess this is because the connection is opened/closes at each call.

Regards
Ronan-Yann Lorin                tél: +33 610 927 199
3, Allée des Hirondelles        tél: +33 134 506 034
95220 Herblay                   mailto:ronan-yann@lorin.nom.fr
France                          http://lorin.nom.fr
----- Message d'origine -----
De : "Berin Loritsch" <bl...@apache.org>
À : "Avalon Developers List" <av...@jakarta.apache.org>
Envoyé : lundi 31 décembre 2001 14:40
Objet : Re: JdbcDataSource pool


> Ronan-Yann Lorin wrote:
>
> > Hi,
> >
> > I'm new to Avalon/Exvalibur and manage to use it in a new project. It
will
> > be a Java server side application running in a servlet container. My
first
> > need is to have a connection pooling package (and a server framework).
> > Avalon looks interesting for this duty.
> >
> > I tried the datasource package (which I like for it's xml configuration
> > file). It gives me very poor performances with my JSP test page. I
suspect
> > it's because of the datasource component opening/closing JDBC
connections
> > and not working as a classical connection pool (get/release).
> >
> > What would be the right solution?
>
>
> There can be a number of reasons for this.  I was in the midst of making
fixes,
> but am officially out of time (my boss read me the riot act).
>
> Can you tell me exactly what your issues are?
>
> How are you setting up the Connection Pool?
>
> Are you instantiating a new pool on every request?  If so, no wonder!
> Please post some more specifics regarding how you are using it in your
system.
> You can hide the actual queries and change the connection info when you
post.
> I am concerned with methodology--it could be something you are not doing
right.
>
>
> >
> > Thanks in advance for your help.
> >
> > Ronan-Yann Lorin  tél: +33 610 927 199
> > 3, Allée des Hirondelles tél: +33 134 506 034
> > 95220 Herblay   mailto:ronan-yann@lorin.nom.fr
> > France    http://lorin.nom.fr
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> > .
> >
> >
>
>
>
> --
>
> "They that give up essential liberty to obtain a little temporary safety
>   deserve neither liberty nor safety."
>                  - Benjamin Franklin
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JdbcDataSource pool

Posted by Ronan-Yann Lorin <ro...@lorin.nom.fr>.
Thanks for your help.

I set up data source at startup in with the following lines:
 public DataSourceComponent  scoringDataSource = null;
  ComponentSelector dbSelector =
(ComponentSelector)_excalibur.lookup("com.banqueagf.business.server.DataSour
ceComponentSelector");
  scoringDataSource = (DataSourceComponent)dbSelector.select("scoring");
Sorry, I forgot the datasource config at office. I connect to an Oracle
database.

I use the connection in a servlet service routine:
  Connection  con;

  con = Server.getServer().scoringDataSource.getConnection();
  PreparedStatement  stmt = con.prepareStatement("SELECT agf, sofinco,
inconnu, habit FROM transc WHERE agf = ?");
  stmt.setString(1, matricule.toUpperCase());
                ResultSet rs = stmt.executeQuery();
         if (rs.next()) {
   if (rs.getString("habit").compareTo("O") == 0) {
    allowed = true;
   } else {
    allowed = false;
   }
   result = new LoanHabilitationData(rs.getString("agf"),
rs.getString("sofinco"), allowed);
  } else {
   result = null;
  }
  rs.close();

  con.close();

When I make multiple calls, I get 5 times better response time with Turbine.
So I guess this is because the connection is opened/closes at each call.

Regards
Ronan-Yann Lorin                tél: +33 610 927 199
3, Allée des Hirondelles        tél: +33 134 506 034
95220 Herblay                   mailto:ronan-yann@lorin.nom.fr
France                          http://lorin.nom.fr
----- Message d'origine -----
De : "Berin Loritsch" <bl...@apache.org>
À : "Avalon Developers List" <av...@jakarta.apache.org>
Envoyé : lundi 31 décembre 2001 14:40
Objet : Re: JdbcDataSource pool


> Ronan-Yann Lorin wrote:
>
> > Hi,
> >
> > I'm new to Avalon/Exvalibur and manage to use it in a new project. It
will
> > be a Java server side application running in a servlet container. My
first
> > need is to have a connection pooling package (and a server framework).
> > Avalon looks interesting for this duty.
> >
> > I tried the datasource package (which I like for it's xml configuration
> > file). It gives me very poor performances with my JSP test page. I
suspect
> > it's because of the datasource component opening/closing JDBC
connections
> > and not working as a classical connection pool (get/release).
> >
> > What would be the right solution?
>
>
> There can be a number of reasons for this.  I was in the midst of making
fixes,
> but am officially out of time (my boss read me the riot act).
>
> Can you tell me exactly what your issues are?
>
> How are you setting up the Connection Pool?
>
> Are you instantiating a new pool on every request?  If so, no wonder!
> Please post some more specifics regarding how you are using it in your
system.
> You can hide the actual queries and change the connection info when you
post.
> I am concerned with methodology--it could be something you are not doing
right.
>
>
> >
> > Thanks in advance for your help.
> >
> > Ronan-Yann Lorin  tél: +33 610 927 199
> > 3, Allée des Hirondelles tél: +33 134 506 034
> > 95220 Herblay   mailto:ronan-yann@lorin.nom.fr
> > France    http://lorin.nom.fr
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> > .
> >
> >
>
>
>
> --
>
> "They that give up essential liberty to obtain a little temporary safety
>   deserve neither liberty nor safety."
>                  - Benjamin Franklin
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: JdbcDataSource pool

Posted by Berin Loritsch <bl...@apache.org>.
Ronan-Yann Lorin wrote:

> Hi,
> 
> I'm new to Avalon/Exvalibur and manage to use it in a new project. It will
> be a Java server side application running in a servlet container. My first
> need is to have a connection pooling package (and a server framework).
> Avalon looks interesting for this duty.
> 
> I tried the datasource package (which I like for it's xml configuration
> file). It gives me very poor performances with my JSP test page. I suspect
> it's because of the datasource component opening/closing JDBC connections
> and not working as a classical connection pool (get/release).
> 
> What would be the right solution?


There can be a number of reasons for this.  I was in the midst of making fixes,
but am officially out of time (my boss read me the riot act).

Can you tell me exactly what your issues are?

How are you setting up the Connection Pool?

Are you instantiating a new pool on every request?  If so, no wonder!
Please post some more specifics regarding how you are using it in your system.
You can hide the actual queries and change the connection info when you post.
I am concerned with methodology--it could be something you are not doing right.


> 
> Thanks in advance for your help.
> 
> Ronan-Yann Lorin  tél: +33 610 927 199
> 3, Allée des Hirondelles tél: +33 134 506 034
> 95220 Herblay   mailto:ronan-yann@lorin.nom.fr
> France    http://lorin.nom.fr
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> .
> 
> 



-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>