[Pljava-dev] pljava reninitializing jdbc connection pool for every invocation

From: sdandapani at counterpane(dot)com (Sriram Dandapani)
To:
Subject: [Pljava-dev] pljava reninitializing jdbc connection pool for every invocation
Date: 2006-03-21 06:56:27
Message-ID: 6992E470F12A444BB787B5C937B9D4DF03C489B1@ca-mail1.cis.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Hi

Following is the scenario:

A plpgsql function calls a java method using pljava. The initialization
of the jdbc pool seems to be happening with every call to the
getConnection method.

Is there a way to implement singletons within pljava

This is the java code that initializes the pool

private static Jdbc3PoolingDataSource pool;

private static Logger logger = Logger.getLogger(PostgresAdapter.class);

private static PropertyResourceBundle resourceBundle;

public static void setupPool() throws Exception
{

logger.info("***setting up postgres
pool");

PropertyResourceBundle
resourceBundle = null;

resourceBundle = new
PropertyResourceBundle(new FileInputStream("postgres-ds.properties"));

pool = new Jdbc3PoolingDataSource();

logger.info("***finished setting up
postgres pool");


pool.setServerName(resourceBundle.getString("serverName"));


pool.setPortNumber(Integer.parseInt(resourceBundle.getString("portNumber
")));


pool.setDatabaseName(resourceBundle.getString("databaseName"));


pool.setUser(resourceBundle.getString("user"));


pool.setPassword(resourceBundle.getString("password"));

pool.setMaxConnections(25);

}

public static Connection getConnection() throws
Exception {

if(pool == null) {

setupPool();

}

Connection con =
pool.getConnection();

con.setAutoCommit(false);

return con;

}

Many thx in advance for answers

Sriram

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pgfoundry.org/pipermail/pljava-dev/attachments/20060320/3c1ff720/attachment.html>

Responses

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2006-03-21 07:14:50 [Pljava-dev] pljava reninitializing jdbc connection pool for every invocation
Previous Message Thomas Hallgren 2006-03-20 10:41:01 [Pljava-dev] Fw: out of memery