agora inbox for pgsql-interfaces@postgresql.org
help / color / mirror / Atom feedJDBC API to send SimpleQuery ('Q')?
4+ messages / 2 participants
[nested] [flat]
* JDBC API to send SimpleQuery ('Q')?
@ 2014-04-25 15:10 Karthik Segpi <karthik.segpi@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Karthik Segpi @ 2014-04-25 15:10 UTC (permalink / raw)
To: pgsql-interfaces
I have the following Java code running in tomcat 7 using
'postgresql-9.3-1101-jdbc41.jar' driver.
String str = "insert into tab1(a,b) values ('name', 'address');"
Statement stmt = conn.createStatement();
stmt.execute(str);
Considering that this is *not* a PreparedStatement, I would have expected
the driver to issue a Simple Query ('Q') instead of an ExtendedQuery ('P').
However, when I print the incoming connection at my middleware (pgpool), I
see the query being received is an ExtendedQuery ('P'). When I execute the
same query in psql, it triggers a Simple Query ('Q') as expected.
What am I missing here? Are there any other settings that I need to tweak?
Thanks
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: JDBC API to send SimpleQuery ('Q')?
@ 2014-04-25 15:30 Tom Lane <tgl@sss.pgh.pa.us>
parent: Karthik Segpi <karthik.segpi@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2014-04-25 15:30 UTC (permalink / raw)
To: Karthik Segpi <karthik.segpi@gmail.com>; +Cc: pgsql-interfaces
Karthik Segpi <karthik.segpi@gmail.com> writes:
> I have the following Java code running in tomcat 7 using
> 'postgresql-9.3-1101-jdbc41.jar' driver.
> String str = "insert into tab1(a,b) values ('name', 'address');"
> Statement stmt = conn.createStatement();
> stmt.execute(str);
> Considering that this is *not* a PreparedStatement, I would have expected
> the driver to issue a Simple Query ('Q') instead of an ExtendedQuery ('P').
> However, when I print the incoming connection at my middleware (pgpool), I
> see the query being received is an ExtendedQuery ('P'). When I execute the
> same query in psql, it triggers a Simple Query ('Q') as expected.
You'd be better off asking about the behavior of the JDBC driver on
pgsql-jdbc, but offhand I see nothing unreasonable about it if they
choose to use extended query protocol exclusively. Less code for
them to maintain, and it's not really less efficient as long as they
ensure messages get grouped into network packets appropriately.
(psql goes the other direction, and doesn't use extended protocol
at all, AFAIR.)
> What am I missing here? Are there any other settings that I need to tweak?
I think you could still force use of simple query mode by telling the
driver to use protocol version 2, but that has lots of downsides.
regards, tom lane
--
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] JDBC API to send SimpleQuery ('Q')?
@ 2014-04-25 15:54 Karthik Segpi <karthik.segpi@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Karthik Segpi @ 2014-04-25 15:54 UTC (permalink / raw)
To: pgsql-jdbc@postgresql.org
I have the following Java code running in tomcat 7 using
'postgresql-9.3-1101-jdbc41.jar' driver.
String str = "insert into tab1(a,b) values ('name', 'address');"
Statement stmt = conn.createStatement();
stmt.execute(str);
Considering that this is *not* a PreparedStatement, I would have expected
the driver to issue a Simple Query ('Q') instead of an ExtendedQuery ('P').
However, when I print the incoming connection at my middleware (pgpool), I
see the query being received is an ExtendedQuery ('P'). When I execute the
same query in psql, it triggers a Simple Query ('Q') as expected.
What am I missing here? Are there any other settings that I need to tweak?
Thanks
On Fri, Apr 25, 2014 at 11:30 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Karthik Segpi <karthik.segpi@gmail.com> writes:
> > I have the following Java code running in tomcat 7 using
> > 'postgresql-9.3-1101-jdbc41.jar' driver.
>
> > String str = "insert into tab1(a,b) values ('name', 'address');"
> > Statement stmt = conn.createStatement();
> > stmt.execute(str);
>
> > Considering that this is *not* a PreparedStatement, I would have expected
> > the driver to issue a Simple Query ('Q') instead of an ExtendedQuery
> ('P').
> > However, when I print the incoming connection at my middleware (pgpool),
> I
> > see the query being received is an ExtendedQuery ('P'). When I execute
> the
> > same query in psql, it triggers a Simple Query ('Q') as expected.
>
> You'd be better off asking about the behavior of the JDBC driver on
> pgsql-jdbc, but offhand I see nothing unreasonable about it if they
> choose to use extended query protocol exclusively. Less code for
> them to maintain, and it's not really less efficient as long as they
> ensure messages get grouped into network packets appropriately.
>
> (psql goes the other direction, and doesn't use extended protocol
> at all, AFAIR.)
>
> > What am I missing here? Are there any other settings that I need to
> tweak?
>
> I think you could still force use of simple query mode by telling the
> driver to use protocol version 2, but that has lots of downsides.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [INTERFACES] JDBC API to send SimpleQuery ('Q')?
@ 2014-04-25 15:56 Karthik Segpi <karthik.segpi@gmail.com>
parent: Karthik Segpi <karthik.segpi@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Karthik Segpi @ 2014-04-25 15:56 UTC (permalink / raw)
To: pgsql-jdbc@postgresql.org
Thanks Tom. I just posted the question to 'pgsql-jdbc' and will follow up
there.
On Fri, Apr 25, 2014 at 11:54 AM, Karthik Segpi <karthik.segpi@gmail.com>wrote:
> I have the following Java code running in tomcat 7 using
> 'postgresql-9.3-1101-jdbc41.jar' driver.
>
> String str = "insert into tab1(a,b) values ('name', 'address');"
> Statement stmt = conn.createStatement();
> stmt.execute(str);
>
> Considering that this is *not* a PreparedStatement, I would have expected
> the driver to issue a Simple Query ('Q') instead of an ExtendedQuery ('P').
> However, when I print the incoming connection at my middleware (pgpool), I
> see the query being received is an ExtendedQuery ('P'). When I execute the
> same query in psql, it triggers a Simple Query ('Q') as expected.
>
> What am I missing here? Are there any other settings that I need to tweak?
>
> Thanks
>
>
> On Fri, Apr 25, 2014 at 11:30 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
>> Karthik Segpi <karthik.segpi@gmail.com> writes:
>> > I have the following Java code running in tomcat 7 using
>> > 'postgresql-9.3-1101-jdbc41.jar' driver.
>>
>> > String str = "insert into tab1(a,b) values ('name', 'address');"
>> > Statement stmt = conn.createStatement();
>> > stmt.execute(str);
>>
>> > Considering that this is *not* a PreparedStatement, I would have
>> expected
>> > the driver to issue a Simple Query ('Q') instead of an ExtendedQuery
>> ('P').
>> > However, when I print the incoming connection at my middleware
>> (pgpool), I
>> > see the query being received is an ExtendedQuery ('P'). When I execute
>> the
>> > same query in psql, it triggers a Simple Query ('Q') as expected.
>>
>> You'd be better off asking about the behavior of the JDBC driver on
>> pgsql-jdbc, but offhand I see nothing unreasonable about it if they
>> choose to use extended query protocol exclusively. Less code for
>> them to maintain, and it's not really less efficient as long as they
>> ensure messages get grouped into network packets appropriately.
>>
>> (psql goes the other direction, and doesn't use extended protocol
>> at all, AFAIR.)
>>
>> > What am I missing here? Are there any other settings that I need to
>> tweak?
>>
>> I think you could still force use of simple query mode by telling the
>> driver to use protocol version 2, but that has lots of downsides.
>>
>> regards, tom lane
>>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2014-04-25 15:56 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-25 15:10 JDBC API to send SimpleQuery ('Q')? Karthik Segpi <karthik.segpi@gmail.com>
2014-04-25 15:30 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-04-25 15:54 ` Karthik Segpi <karthik.segpi@gmail.com>
2014-04-25 15:56 ` Karthik Segpi <karthik.segpi@gmail.com>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox