[Pljava-dev] Newbie Questions

From: thomas at tada(dot)se (Thomas Hallgren)
To:
Subject: [Pljava-dev] Newbie Questions
Date: 2006-09-29 19:12:00
Message-ID: 451D7000.70406@tada.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pljava-dev

Scott Petersen wrote:
> Folks,
>
> YES, I am a newbie. But I have been tasked to verify several questions
> specific to the PLJava implementation (version 1.3. 0, Postgresql
> 8.1+). I have read the manual at
> http://wiki.tada.se/wiki/display/pljava/The+choice+of+JNI which has been
> most helpful and informative. But I need to verify the following:
>
> 1) When I create a connection "Connection db =
> DriverManager.getConnection("jdbc:default:connection");", does this
> reuse/copy/duplicate the existing connection or does it create a new
> (second) connection to the database?
>
>
Well, that depends on how you look at it. Let me elaborate:

You start with a client application. If you use Java, you will probably
use JDBC but the same is true if you use the psql client or something
else. This application will utilize some kind of IPC mechanism (often a
socket) and connect your client process to the backend server process.
The first time the backend server process executes a Java function, it
will instantiate a JVM. If the Java method in turn uses the
getConnection() method that you give in your example, it will establish
an *internal* connection within the backend. Unlike the the socket
connection, this connection is in-process, has very low overhead, and
executes within the same transaction as the caller.

> 2) In reading the above referenced web page it appears that each
> connection has its own JVM. Is this true, or is there a single JVM per
> schema, or a single JVM per database?
>
>
It's a single JVM per client connection. I recommend reading
http://wiki.tada.se/wiki/display/pljava/The+choice+of+JNI for a deeper
understanding of the choice of technology.

Kind Regards,
Thomas Hallgren

In response to

Browse pljava-dev by date

  From Date Subject
Next Message Thomas Hallgren 2006-10-01 11:53:52 [Pljava-dev] VarLenTuple example code
Previous Message Scott Petersen 2006-09-29 18:46:42 [Pljava-dev] Newbie Questions