[Pljava-dev] closing jdbc connections within pljava calls

Thomas Hallgren thomas at tada.se
Tue Apr 11 20:30:18 UTC 2006


Hi Sriram,
The JVM will not terminate until your session terminates and the fact 
that the connection remains opened will be harmless. You will waste 
resources at worst since the backend process that sits at the end of 
that connection remains alive until the connection is closed. My guess 
is that this "waste" is a good thing since you don't need to reestablish 
the connection in case you call your plpgsql function repeatedly.

I'm not 100% sure what happens to the backend process at the other end 
of your connection when the JVM terminates. My guess is that it will 
terminate gracefully when it senses that the socket is closed. But you 
will not have a transaction active when that happens anyway so it 
shouldn't matter much.

Regards,
Thomas Hallgren



Sriram Dandapani wrote:
>
> Hi
>
> I am implementing autonomous transactions by making a pljava call…and 
> within the java function, I obtain a jdbc connection using the 
> postgresql driver.
>
> During a regular plpgsql function call, several calls are made to this 
> java function.
>
> Should I close the jdbc connection when the plgsql function 
> terminates..or does the fact that the jvm is terminated sufficient ? 
> What is the impact of not closing the jdbc connection ? The reason I 
> ask is because an error could cause the plpsql function to terminate 
> abnormally.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pljava-dev mailing list
> Pljava-dev at gborg.postgresql.org
> http://gborg.postgresql.org/mailman/listinfo/pljava-dev
>   




More information about the Pljava-dev mailing list