Re: JDBC API to send SimpleQuery ('Q')?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Karthik Segpi <karthik(dot)segpi(at)gmail(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: JDBC API to send SimpleQuery ('Q')?
Date: 2014-04-25 15:30:18
Message-ID: 7737.1398439818@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces pgsql-jdbc

Karthik Segpi <karthik(dot)segpi(at)gmail(dot)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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Karthik Segpi 2014-04-25 15:54:46 Re: [INTERFACES] JDBC API to send SimpleQuery ('Q')?
Previous Message Karthik Segpi 2014-04-25 15:10:43 JDBC API to send SimpleQuery ('Q')?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Karthik Segpi 2014-04-25 15:54:46 Re: [INTERFACES] JDBC API to send SimpleQuery ('Q')?
Previous Message Karthik Segpi 2014-04-25 15:10:43 JDBC API to send SimpleQuery ('Q')?