Re: setUseServerPrepare(true) and executeQuery(String) - Mailing list pgsql-jdbc

From Harald Krake
Subject Re: setUseServerPrepare(true) and executeQuery(String)
Date
Msg-id 200212011136.39006.harald@krake.de
Whole thread Raw
In response to Re: setUseServerPrepare(true) and executeQuery(String)  (Barry Lind <blind@xythos.com>)
List pgsql-jdbc
On Sunday 01 December 2002 09:43 am, Barry Lind wrote:
> Why would you want to disable caching for standard jdbc statements
> plans?
> If you don't wan't to use a server side prepared and cached plan,
> then don't enable it for your regular jdbc statement objects.

Hi Barry,

this means that I have to put postgres-specific java code into my
application. I don't like that, because jdbc is an _abstraction_ layer and
already provides two query types: prepared and non-prepared.
If the query is a one time shot: use executeQuery(String).
If you're able to factor out parameters from the query string and/or there's
a potential for it getting reused: prepare it and use executeQuery().
So, according to the jdbc api it's up to the java programmer to decide
which statements get prepared and which are one time shots. There is
no need for an extra method, especially a dbms-specific one.
Consequently, the postgres-jdbc driver should prepare a server object
in the prepareStatement()-method and not in executeQuery() as
it is now.
At least, this is how the jdbc api was designed and what a java programmer
expects.
It's fine to provide an extra switch that turns on server side prepares
even for non-prepared queries, but this should be an option (best in the url)
cause it's a non-standard behaviour that would badly waste resources
in some applications (imagine a typical query-by-forms app).

Harald.


pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: setUseServerPrepare(true) and executeQuery(String)
Next
From: pginfo
Date:
Subject: pg 7.3 , JDBC and timestamp problem.