tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DE VINZELLES, Guillaume \(ext.\)" <>
Subject RE: JDBC Pool exhaustion
Date Wed, 11 Oct 2006 14:40:53 GMT
For Christopher and Alberty, here is an example of how we connect to the database. I'm quite
sure we are using the JDBC pool.
My next step is to try to log the Connection objects life, and I hope to find some memory
I got to say that we were using the same application with a Tomcat 4 and a JVM 1.4.08 without
any problem.

Thanks for your previous answers!

DataSource ds;
String datasource = "jdbc/Signup";

try {
	Context ic = new InitialContext();
      Context envCtx = (Context) ic.lookup("java:/comp/env");
      ds = (DataSource) envCtx.lookup(datasource);
catch (NamingException ne) {
      logger.error("Error looking up datasource jdbc/Signup : " + 	e.getMessage());
Connection myConnection = null;
CallableStatement oCmd = null;
ResultSet result = null;

try {
   	myConnection = ds.getConnection();
     	oCmd = myConnection.prepareCall("{call STOREDPROC(?, ?)}");
	oCmd.registerOutParameter(1, OracleTypes.CURSOR);
	oCmd.setString(2, critere);
	result = (ResultSet)oCmd.getObject(1);

	/* SNIP */	
catch (Exception e) {   
	logger.error(e.getMessage(), e);
	throw new DepotGarantieNotFoundException("Erreur SQL", e);
finally {
	try {
		if (result != null) {
			result = null;
		if (oCmd != null) {
			oCmd = null;
		if (myConnection != null) {
			myConnection = null;
	} catch (SQLException e) {}

Guillaume de Vinzelles
DSI/PFS Neuf Cegetel
Altran Technologies
01 70 18 21 64

-----Message d'origine-----
De : Christopher Schultz [] 
Envoyé : mercredi 11 octobre 2006 16:20
À : Tomcat Users List
Objet : Re: JDBC Pool exhaustion


> <Resource name="jdbc/Signup" auth="Container"
> type="javax.sql.DataSource" 
> driverClassName="oracle.jdbc.driver.OracleDriver"
> The Tomcat manager shows around 1000 sessions on the server, which
> seems to be pertinent.

What is your connection allocation strategy? Meaning: do you allocate a
Connection object to each session for the life of the session, or do you
use some kind of pooling mechanism and only fetch Connection objects
when you need to execute a query?

If you associate a Connection with each session, I would strongly
recommend that you use pooling as described above.

If you are already using pooling (which it looks like you /are/ given
your configuration), then you might have a connection leak in one or
more places.

How are you actually getting and releasing your connections?

> We can see with the JMXProxy that the JDBC pool connections are never
> recycled, e.g. the active connections number is going higher and 
> higher and never stays at the same level, which is strange because 
> the amount of active sessions isn't growing.

Does your connection count grow larger than 150 (your maxActive number)?
Perhaps you really do need that number of connections if you have 1000

> Do you have any idea about what we can do to 'force' the Tomcat 
> server to release the unused JDBC connections?

Tomcat isn't in charge of your connections... the Oracle driver is.
You'd have to look at how they are being used.


To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message