Re: Statement.setQueryTimeout() with autoCommit=false

From: dmp <danap(at)ttc-cmc(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: pavel(dot)arnost(at)loutka(dot)cz
Subject: Re: Statement.setQueryTimeout() with autoCommit=false
Date: 2012-12-06 18:14:50
Message-ID: 50C0E09A.4070408@ttc-cmc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Exactly.

According to the Java API:

void setAutoCommit(boolean autoCommit) throws SQLException

Sets this connection's auto-commit mode to the given state. If a connection
is in auto-commit mode, then all its SQL statements will be executed and
committed as individual transactions. Otherwise, its SQL statements are grouped
into transactions that are terminated by a call to either the method commit or
the method rollback. By default, new connections are in auto-commit mode.

By setting setAutoCommit(false) you are deciding to tell the database your code
will determine when to commit the transaction. Thereby I would say overiding
setQueryTimeout().

danap.

Dave Cramer wrote:
> Why would the query timeout at all ?
>
> The query timeout is for long running queries. If the query takes longer
> than n seconds it will timeout.
>
> Dave
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca
>
>
>
> On Thu, Dec 6, 2012 at 12:04 PM, <pavel(dot)arnost(at)loutka(dot)cz
> <mailto:pavel(dot)arnost(at)loutka(dot)cz>> wrote:
>
> Hi,
>
> does setQueryTimeout work with autoCommit=false? When autoCommit is
> true, this code timeouts after 5 seconds (as expected):
>
> ~
> ~
> ~
> --
>
> But if I set autoCommit to false, this code timeouts after 30
> seconds on read timeout:
>
> --
> ~
> ~
> ~
> --
>
> I'm confused what's setQueryTimeout() method for, why it doesn't
> work with manual transactions?

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Johnston 2012-12-06 18:36:53 Re: Statement.setQueryTimeout() with autoCommit=false
Previous Message Dave Cramer 2012-12-06 17:54:48 Re: Statement.setQueryTimeout() with autoCommit=false