Yes i too tried the same connection pooling and found for each and every time it
has been increased to one.
I have found it were it is increasing. Here is the snippet of code from Jason
Hunters Book
<snip>
synchronized(prh_Connections){
System.out.println("Entering synchronized block");
while(key.hasMoreElements()){
locon_Conn = (Connection)key.nextElement();
}
Boolean b = (Boolean)prh_Connections.get(locon_Conn);
if (b == Boolean.TRUE){
try{
String lows_Dbquery = "select * from gen1";
Statement lostmt_State = locon_Conn.createStatement();
lostmt_State.executeQuery(lows_Dbquery);
}
catch(SQLException sqle){
locon_Conn = DriverManager.getConnection(prws_Dburl, prws_Usrname,
prws_Password);
}
***********************************************
System.out.println("Returning :" + prh_Connections.size());
prh_Connections.put(locon_Conn, Boolean.FALSE);
System.out.println("Returning After:" + prh_Connections.size());
**************************************************
}
}
</snip>
<op>
Returning :2
Returning After:3 [Increasing the hashtable by 1 instead it need to update the
same connection by a false value to makr that it has been taken]
</op>
In the above snip the line marked with asterix is updating the hashtable with a
false value stating that this connection has been taking. Hashtable is growing
by one at this juncture instead it need to update its value. Since it has been
increased by 1 it grows beyond a limit at certain stage and maximum number of
connection exceeds.
Any workaround??
Thanks
Srini
RVASUDEV wrote:
> See at <VR>
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> Vasudev Ram
> Infosys Technologies Limited
> Pune, India
> Email : [EMAIL PROTECTED]
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> > -----Original Message-----
> > From: Hunter Hillegas [SMTP:[EMAIL PROTECTED]]
> > Sent: Friday, December 17, 1999 11:23 AM
> > To: [EMAIL PROTECTED]
> > Subject: ConnectionPool
> >
> > Hi!
> >
> > I'm using the ConnectionPool example from Jason Hunter's book with my
> > servlets and a mySQL database on Linux...
> >
> > Whenever a query hits the database, it's creating a new connection (it's
> > never reusing a connection from the pool)...
> >
> > I don't really know the best way to troubleshoot this...
> >
> <VR> Open a log file in each of your classes (ConnectionPool,
> YourServletApp)
> and write messages to the log file to show the flow of control
> and variable values.
> </VR>
>
> > The first thing I tried was changing the setup on the ConnectionPool class
> > to perform a simple query I know is valid to perform the check on the
> > Connection object...
> >
> > mySQL doesn't support transactions so I didn't know if
> > con.setAutoCommit(true) would throw an exception (and thus create a new
> > connection) or not...
> >
> <VR> Write a test program to find out if setAutoCommit throws
> exceptions.
> </VR>
>
> > It's still creating a new connection every time so I end up with a VERY
> > large pool that maxes out the DB...
> >
> > Any suggestions?
> >
> > Hunter
> >
> > __________________________________________________________________________
> > _
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html