From: thomas at tada.se (Thomas Hallgren) Date: Tue, 21 Mar 2006 19:37:24 +0100 Subject: [Pljava-dev] pljava reninitializing jdbc connection pool for every invocation In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF03C48AF8@ca-mail1.cis.local> References: <6992E470F12A444BB787B5C937B9D4DF03C48AF8@ca-mail1.cis.local> Message-ID: <442047E4.2020707@tada.se> Sriram Dandapani wrote: > Ok..the picture is getting clearer.. This is what we do > > The java method that is called using pljava obtains a jdbc connection > using the postgresql driver because we need the autonomous transaction > feature. > > When a postgres function calls this pljava function, every invocation > results in a new connection being obtained. Since we do not use > pljava.jar to obtain this connection, am I losing out on the nice > in-process features you mentioned. > > Well, you can never have autonomous transactions in-process when you use PostgreSQL. But there's no need for you to create a new remote connection for each and every invocation. Let it be created in your first call. Store it in a static variable and reuse it on all subsequent calls. Make sure each call performs a commit or rollback on it but don't close it. Regards, Thomas Hallgren