Thread: JDBC warning on setAutoCommit(false)

JDBC warning on setAutoCommit(false)

From
Dustin Sallings
Date:
    I've got some code that abstracts JDBC connections and does all
kinds of magic for me.  One of things it does is, when returning a
connection to the pool, it looks for any SQLWarnings the connection
contains.  I've got a few things that begin transactions by setting
autocommit to false, then do some work, then commit (or rollback), and
then set autocommit back to true.  When the connection is returned to the
DB, the following warning is issued:

java.sql.SQLWarning: WARNING:  COMMIT: no transaction in progress
    at org.postgresql.jdbc1.AbstractJdbc1Connection.addWarning(AbstractJdbc1Connection.java:430)
    at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:111)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
    at org.postgresql.jdbc1.AbstractJdbc1Connection.setAutoCommit(AbstractJdbc1Connection.java:942)
    [...my code...]

    This doesn't seem like the right thing to do...I should be able to
enable autocommit without a warning when a transaction is not in progress.
If anything, I should get a warning is there *is* a transaction in
progress.

--
SPY                      My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________

Re: JDBC warning on setAutoCommit(false)

From
Barry Lind
Date:
Dustin,

Please provide more info, like what versions you are using (both server
and driver) as well as a test case that reproduces the problem.

--Barry


Dustin Sallings wrote:
>     I've got some code that abstracts JDBC connections and does all
> kinds of magic for me.  One of things it does is, when returning a
> connection to the pool, it looks for any SQLWarnings the connection
> contains.  I've got a few things that begin transactions by setting
> autocommit to false, then do some work, then commit (or rollback), and
> then set autocommit back to true.  When the connection is returned to the
> DB, the following warning is issued:
>
> java.sql.SQLWarning: WARNING:  COMMIT: no transaction in progress
>     at org.postgresql.jdbc1.AbstractJdbc1Connection.addWarning(AbstractJdbc1Connection.java:430)
>     at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:111)
>     at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:482)
>     at org.postgresql.jdbc1.AbstractJdbc1Connection.ExecSQL(AbstractJdbc1Connection.java:461)
>     at org.postgresql.jdbc1.AbstractJdbc1Connection.setAutoCommit(AbstractJdbc1Connection.java:942)
>     [...my code...]
>
>     This doesn't seem like the right thing to do...I should be able to
> enable autocommit without a warning when a transaction is not in progress.
> If anything, I should get a warning is there *is* a transaction in
> progress.
>
> --
> SPY                      My girlfriend asked me which one I like better.
> pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
> |    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
> L_______________________ I hope the answer won't upset her. ____________
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>