pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedgetAutocommit assertion error
11+ messages / 5 participants
[nested] [flat]
* getAutocommit assertion error
@ 2018-11-12 13:10 adrien ruffie <adriennolarsen@hotmail.fr>
0 siblings, 2 replies; 11+ messages in thread
From: adrien ruffie @ 2018-11-12 13:10 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org <pgsql-jdbc@lists.postgresql.org>
Hello all,
in my java test case launched by maven I get the following exception:
java.lang.AssertionError: pgStatement.getConnection().getAutoCommit() should not throw
But I don't know why this error is returned ...
In my class, I set auto commit to 'false' value, and I commit at the ending like this:
try {
preparedStatement.close();
connection.commit();
} catch (SQLException e) {
log.error("Error while closing connection.", e.toString());
}
I check where the error comme from and I just found the following code, in BatchResultHandler:
private boolean isAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
I don't really understand the problem ...
anyone can help me please ?
Best regards,
Adrien
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-12 22:43 Dave Cramer <pg@fastcrypt.com>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 0 replies; 11+ messages in thread
From: Dave Cramer @ 2018-11-12 22:43 UTC (permalink / raw)
To: adriennolarsen@hotmail.fr; +Cc: pgsql-jdbc@lists.postgresql.org
My best guess is that you should be committing before closing the statement.
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On Mon, 12 Nov 2018 at 09:39, adrien ruffie <adriennolarsen@hotmail.fr>
wrote:
> Hello all,
>
>
> in my java test case launched by maven I get the following exception:
>
>
> java.lang.AssertionError: pgStatement.getConnection().getAutoCommit()
> should not throw
>
> But I don't know why this error is returned ...
>
> In my class, I set auto commit to 'false' value, and I commit at the
> ending like this:
>
>
> try {
> preparedStatement.close();
> connection.commit();
> } catch (SQLException e) {
> log.error("Error while closing connection.", e.toString());
> }
>
> I check where the error comme from and I just found the following code, in
> BatchResultHandler:
>
>
> private boolean isAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should
> not throw";
> return false;
> }
> }
>
>
>
> I don't really understand the problem ...
>
> anyone can help me please ?
>
>
> Best regards,
>
>
> Adrien
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* RE: getAutocommit assertion error
@ 2018-11-13 08:19 adrien ruffie <adriennolarsen@hotmail.fr>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 2 replies; 11+ messages in thread
From: adrien ruffie @ 2018-11-13 08:19 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org <pgsql-jdbc@lists.postgresql.org>
Hello Dave,
thank you for your advise, but unfortunately that not really change ...
even by reversing the 2 lines, I still have the problem.
It's very strange in source code
private booleanisAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
because you can't really see the really SQLException which should throws in order ot really debug the problem ...
I have tried to find in postgres site, in jdbc driver topic and thread in internet but nothing :-(
________________________________
De : adrien ruffie <adriennolarsen@hotmail.fr>
Envoyé : lundi 12 novembre 2018 14:10:50
À : pgsql-jdbc@lists.postgresql.org
Objet : getAutocommit assertion error
Hello all,
in my java test case launched by maven I get the following exception:
java.lang.AssertionError: pgStatement.getConnection().getAutoCommit() should not throw
But I don't know why this error is returned ...
In my class, I set auto commit to 'false' value, and I commit at the ending like this:
try {
preparedStatement.close();
connection.commit();
} catch (SQLException e) {
log.error("Error while closing connection.", e.toString());
}
I check where the error comme from and I just found the following code, in BatchResultHandler:
private boolean isAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
I don't really understand the problem ...
anyone can help me please ?
Best regards,
Adrien
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-13 08:39 Jens Carlberg <jens.carlberg@gmail.com>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 1 reply; 11+ messages in thread
From: Jens Carlberg @ 2018-11-13 08:39 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org
Hi.
If you can, I suggest you run in debug and put a breakpoint in the method,
so you can examine the thrown exception (or trace the call deeper). In
Eclipse, it would be Run -> Debug As -> Maven Test (assuming this is when
you run the tests). I have no experience in how to do this in other
environment, but I assume other IDE:s at least have similar functionality.
If you are using maven on the command line, this thread on StackOverflow
might be helpful:
https://stackoverflow.com/questions/2935375/debugging-in-maven
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:19, adrien ruffie <adriennolarsen@hotmail.fr>
wrote:
> Hello Dave,
>
> thank you for your advise, but unfortunately that not really change ...
> even by reversing the 2 lines, I still have the problem.
>
> It's very strange in source code
>
> private booleanisAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should not
> throw";
> return false;
> }
> }
>
> because you can't really see the really SQLException which should throws
> in order ot really debug the problem ...
> I have tried to find in postgres site, in jdbc driver topic and thread in
> internet but nothing :-(
>
> ------------------------------
> *De :* adrien ruffie <adriennolarsen@hotmail.fr>
> *Envoyé :* lundi 12 novembre 2018 14:10:50
> *À :* pgsql-jdbc@lists.postgresql.org
> *Objet :* getAutocommit assertion error
>
>
> Hello all,
>
>
> in my java test case launched by maven I get the following exception:
>
>
> java.lang.AssertionError: pgStatement.getConnection().getAutoCommit()
> should not throw
>
> But I don't know why this error is returned ...
>
> In my class, I set auto commit to 'false' value, and I commit at the
> ending like this:
>
>
> try {
> preparedStatement.close();
> connection.commit();
> } catch (SQLException e) {
> log.error("Error while closing connection.", e.toString());
> }
>
> I check where the error comme from and I just found the following code, in
> BatchResultHandler:
>
>
> private boolean isAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should
> not throw";
> return false;
> }
> }
>
>
>
> I don't really understand the problem ...
>
> anyone can help me please ?
>
>
> Best regards,
>
>
> Adrien
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-13 09:11 Jens Carlberg <jens.carlberg@gmail.com>
parent: Jens Carlberg <jens.carlberg@gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: Jens Carlberg @ 2018-11-13 09:11 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org
After looking at the JDBC code, the only path I see leading to this error
is if the connection has been closed. If nothing else, this might give you
a clue where to look in your test code.
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:39, Jens Carlberg <jens.carlberg@gmail.com> wrote:
> Hi.
>
> If you can, I suggest you run in debug and put a breakpoint in the method,
> so you can examine the thrown exception (or trace the call deeper). In
> Eclipse, it would be Run -> Debug As -> Maven Test (assuming this is when
> you run the tests). I have no experience in how to do this in other
> environment, but I assume other IDE:s at least have similar functionality.
> If you are using maven on the command line, this thread on StackOverflow
> might be helpful:
> https://stackoverflow.com/questions/2935375/debugging-in-maven
>
> Best Regards,
> ///Jens Carlberg
>
>
> On Tue, 13 Nov 2018 at 09:19, adrien ruffie <adriennolarsen@hotmail.fr>
> wrote:
>
>> Hello Dave,
>>
>> thank you for your advise, but unfortunately that not really change ...
>> even by reversing the 2 lines, I still have the problem.
>>
>> It's very strange in source code
>>
>> private booleanisAutoCommit() {
>> try {
>> return pgStatement.getConnection().getAutoCommit();
>> } catch (SQLException e) {
>> assert false : "pgStatement.getConnection().getAutoCommit() should not
>> throw";
>> return false;
>> }
>> }
>>
>> because you can't really see the really SQLException which should throws
>> in order ot really debug the problem ...
>> I have tried to find in postgres site, in jdbc driver topic and thread in
>> internet but nothing :-(
>>
>> ------------------------------
>> *De :* adrien ruffie <adriennolarsen@hotmail.fr>
>> *Envoyé :* lundi 12 novembre 2018 14:10:50
>> *À :* pgsql-jdbc@lists.postgresql.org
>> *Objet :* getAutocommit assertion error
>>
>>
>> Hello all,
>>
>>
>> in my java test case launched by maven I get the following exception:
>>
>>
>> java.lang.AssertionError: pgStatement.getConnection().getAutoCommit()
>> should not throw
>>
>> But I don't know why this error is returned ...
>>
>> In my class, I set auto commit to 'false' value, and I commit at the
>> ending like this:
>>
>>
>> try {
>> preparedStatement.close();
>> connection.commit();
>> } catch (SQLException e) {
>> log.error("Error while closing connection.", e.toString());
>> }
>>
>> I check where the error comme from and I just found the following code,
>> in BatchResultHandler:
>>
>>
>> private boolean isAutoCommit() {
>> try {
>> return pgStatement.getConnection().getAutoCommit();
>> } catch (SQLException e) {
>> assert false : "pgStatement.getConnection().getAutoCommit() should
>> not throw";
>> return false;
>> }
>> }
>>
>>
>>
>> I don't really understand the problem ...
>>
>> anyone can help me please ?
>>
>>
>> Best regards,
>>
>>
>> Adrien
>>
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-13 11:15 Dave Cramer <pg@fastcrypt.com>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 0 replies; 11+ messages in thread
From: Dave Cramer @ 2018-11-13 11:15 UTC (permalink / raw)
To: adriennolarsen@hotmail.fr; +Cc: pgsql-jdbc@lists.postgresql.org
Hello Adrien,
In that case I'd have to see a test case that replicates the problem in
order to be able to help you
Just curious what version of the driver are you using?
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On Tue, 13 Nov 2018 at 03:19, adrien ruffie <adriennolarsen@hotmail.fr>
wrote:
> Hello Dave,
>
> thank you for your advise, but unfortunately that not really change ...
> even by reversing the 2 lines, I still have the problem.
>
> It's very strange in source code
>
> private booleanisAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should not
> throw";
> return false;
> }
> }
>
> because you can't really see the really SQLException which should throws
> in order ot really debug the problem ...
> I have tried to find in postgres site, in jdbc driver topic and thread in
> internet but nothing :-(
>
> ------------------------------
> *De :* adrien ruffie <adriennolarsen@hotmail.fr>
> *Envoyé :* lundi 12 novembre 2018 14:10:50
> *À :* pgsql-jdbc@lists.postgresql.org
> *Objet :* getAutocommit assertion error
>
>
> Hello all,
>
>
> in my java test case launched by maven I get the following exception:
>
>
> java.lang.AssertionError: pgStatement.getConnection().getAutoCommit()
> should not throw
>
> But I don't know why this error is returned ...
>
> In my class, I set auto commit to 'false' value, and I commit at the
> ending like this:
>
>
> try {
> preparedStatement.close();
> connection.commit();
> } catch (SQLException e) {
> log.error("Error while closing connection.", e.toString());
> }
>
> I check where the error comme from and I just found the following code, in
> BatchResultHandler:
>
>
> private boolean isAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should
> not throw";
> return false;
> }
> }
>
>
>
> I don't really understand the problem ...
>
> anyone can help me please ?
>
>
> Best regards,
>
>
> Adrien
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* RE: getAutocommit assertion error
@ 2018-11-14 13:32 adrien ruffie <adriennolarsen@hotmail.fr>
parent: Jens Carlberg <jens.carlberg@gmail.com>
0 siblings, 2 replies; 11+ messages in thread
From: adrien ruffie @ 2018-11-14 13:32 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org <pgsql-jdbc@lists.postgresql.org>
Sorry for this late anwser ...
Dave, for the version of driver is:
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.2</version>
Jens,
I can't debug, because the problem only appears when bamboo lannched my test cases ... impossible to reproduce IDE and Maven command line ...
________________________________
De : Jens Carlberg <jens.carlberg@gmail.com>
Envoyé : mardi 13 novembre 2018 10:11:32
À : pgsql-jdbc@lists.postgresql.org
Objet : Re: getAutocommit assertion error
After looking at the JDBC code, the only path I see leading to this error is if the connection has been closed. If nothing else, this might give you a clue where to look in your test code.
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:39, Jens Carlberg <jens.carlberg@gmail.com<mailto:jens.carlberg@gmail.com>> wrote:
Hi.
If you can, I suggest you run in debug and put a breakpoint in the method, so you can examine the thrown exception (or trace the call deeper). In Eclipse, it would be Run -> Debug As -> Maven Test (assuming this is when you run the tests). I have no experience in how to do this in other environment, but I assume other IDE:s at least have similar functionality. If you are using maven on the command line, this thread on StackOverflow might be helpful: https://stackoverflow.com/questions/2935375/debugging-in-maven
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:19, adrien ruffie <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>> wrote:
Hello Dave,
thank you for your advise, but unfortunately that not really change ...
even by reversing the 2 lines, I still have the problem.
It's very strange in source code
private booleanisAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
because you can't really see the really SQLException which should throws in order ot really debug the problem ...
I have tried to find in postgres site, in jdbc driver topic and thread in internet but nothing :-(
________________________________
De : adrien ruffie <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>>
Envoyé : lundi 12 novembre 2018 14:10:50
À : pgsql-jdbc@lists.postgresql.org<mailto:pgsql-jdbc@lists.postgresql.org>
Objet : getAutocommit assertion error
Hello all,
in my java test case launched by maven I get the following exception:
java.lang.AssertionError: pgStatement.getConnection().getAutoCommit() should not throw
But I don't know why this error is returned ...
In my class, I set auto commit to 'false' value, and I commit at the ending like this:
try {
preparedStatement.close();
connection.commit();
} catch (SQLException e) {
log.error("Error while closing connection.", e.toString());
}
I check where the error comme from and I just found the following code, in BatchResultHandler:
private boolean isAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
I don't really understand the problem ...
anyone can help me please ?
Best regards,
Adrien
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-14 13:33 Dave Cramer <pg@fastcrypt.com>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 1 reply; 11+ messages in thread
From: Dave Cramer @ 2018-11-14 13:33 UTC (permalink / raw)
To: Adrien Ruffie <adriennolarsen@hotmail.fr>; +Cc: pgsql-jdbc@lists.postgresql.org
Adrien,
No reason not to use the latest
42.2.5
Dave Cramer
davec@postgresintl.com
www.postgresintl.com
On Wed, 14 Nov 2018 at 08:32, adrien ruffie <adriennolarsen@hotmail.fr>
wrote:
> Sorry for this late anwser ...
>
> Dave, for the version of driver is:
>
>
> <groupId>org.postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>42.2.2</version>
>
> Jens,
>
> I can't debug, because the problem only appears when bamboo lannched my
> test cases ... impossible to reproduce IDE and Maven command line ...
>
>
> ------------------------------
> *De :* Jens Carlberg <jens.carlberg@gmail.com>
> *Envoyé :* mardi 13 novembre 2018 10:11:32
> *À :* pgsql-jdbc@lists.postgresql.org
> *Objet :* Re: getAutocommit assertion error
>
> After looking at the JDBC code, the only path I see leading to this error
> is if the connection has been closed. If nothing else, this might give you
> a clue where to look in your test code.
>
> Best Regards,
> ///Jens Carlberg
>
> On Tue, 13 Nov 2018 at 09:39, Jens Carlberg <jens.carlberg@gmail.com>
> wrote:
>
> Hi.
>
> If you can, I suggest you run in debug and put a breakpoint in the method,
> so you can examine the thrown exception (or trace the call deeper). In
> Eclipse, it would be Run -> Debug As -> Maven Test (assuming this is when
> you run the tests). I have no experience in how to do this in other
> environment, but I assume other IDE:s at least have similar functionality.
> If you are using maven on the command line, this thread on StackOverflow
> might be helpful:
> https://stackoverflow.com/questions/2935375/debugging-in-maven
>
> Best Regards,
> ///Jens Carlberg
>
>
> On Tue, 13 Nov 2018 at 09:19, adrien ruffie <adriennolarsen@hotmail.fr>
> wrote:
>
> Hello Dave,
>
> thank you for your advise, but unfortunately that not really change ...
> even by reversing the 2 lines, I still have the problem.
>
> It's very strange in source code
>
> private booleanisAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should not
> throw";
> return false;
> }
> }
>
> because you can't really see the really SQLException which should throws
> in order ot really debug the problem ...
> I have tried to find in postgres site, in jdbc driver topic and thread in
> internet but nothing :-(
>
> ------------------------------
> *De :* adrien ruffie <adriennolarsen@hotmail.fr>
> *Envoyé :* lundi 12 novembre 2018 14:10:50
> *À :* pgsql-jdbc@lists.postgresql.org
> *Objet :* getAutocommit assertion error
>
>
> Hello all,
>
>
> in my java test case launched by maven I get the following exception:
>
>
> java.lang.AssertionError: pgStatement.getConnection().getAutoCommit()
> should not throw
>
> But I don't know why this error is returned ...
>
> In my class, I set auto commit to 'false' value, and I commit at the
> ending like this:
>
>
> try {
> preparedStatement.close();
> connection.commit();
> } catch (SQLException e) {
> log.error("Error while closing connection.", e.toString());
> }
>
> I check where the error comme from and I just found the following code, in
> BatchResultHandler:
>
>
> private boolean isAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit() should
> not throw";
> return false;
> }
> }
>
>
>
> I don't really understand the problem ...
>
> anyone can help me please ?
>
>
> Best regards,
>
>
> Adrien
>
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* RE: getAutocommit assertion error
@ 2018-11-14 14:08 adrien ruffie <adriennolarsen@hotmail.fr>
parent: Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 11+ messages in thread
From: adrien ruffie @ 2018-11-14 14:08 UTC (permalink / raw)
To: ; +Cc: pgsql-jdbc@lists.postgresql.org <pgsql-jdbc@lists.postgresql.org>
I changed it, but nothing works... same problem
I am in despair.
________________________________
De : Dave Cramer <pg@fastcrypt.com>
Envoyé : mercredi 14 novembre 2018 14:33:40
À : Adrien Ruffie
Cc : pgsql-jdbc@lists.postgresql.org
Objet : Re: getAutocommit assertion error
Adrien,
No reason not to use the latest
42.2.5
Dave Cramer
davec@postgresintl.com<mailto:davec@postgresintl.com>
www.postgresintl.com<http://www.postgresintl.com;
On Wed, 14 Nov 2018 at 08:32, adrien ruffie <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>> wrote:
Sorry for this late anwser ...
Dave, for the version of driver is:
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.2</version>
Jens,
I can't debug, because the problem only appears when bamboo lannched my test cases ... impossible to reproduce IDE and Maven command line ...
________________________________
De : Jens Carlberg <jens.carlberg@gmail.com<mailto:jens.carlberg@gmail.com>>
Envoyé : mardi 13 novembre 2018 10:11:32
À : pgsql-jdbc@lists.postgresql.org<mailto:pgsql-jdbc@lists.postgresql.org>
Objet : Re: getAutocommit assertion error
After looking at the JDBC code, the only path I see leading to this error is if the connection has been closed. If nothing else, this might give you a clue where to look in your test code.
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:39, Jens Carlberg <jens.carlberg@gmail.com<mailto:jens.carlberg@gmail.com>> wrote:
Hi.
If you can, I suggest you run in debug and put a breakpoint in the method, so you can examine the thrown exception (or trace the call deeper). In Eclipse, it would be Run -> Debug As -> Maven Test (assuming this is when you run the tests). I have no experience in how to do this in other environment, but I assume other IDE:s at least have similar functionality. If you are using maven on the command line, this thread on StackOverflow might be helpful: https://stackoverflow.com/questions/2935375/debugging-in-maven
Best Regards,
///Jens Carlberg
On Tue, 13 Nov 2018 at 09:19, adrien ruffie <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>> wrote:
Hello Dave,
thank you for your advise, but unfortunately that not really change ...
even by reversing the 2 lines, I still have the problem.
It's very strange in source code
private booleanisAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
because you can't really see the really SQLException which should throws in order ot really debug the problem ...
I have tried to find in postgres site, in jdbc driver topic and thread in internet but nothing :-(
________________________________
De : adrien ruffie <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>>
Envoyé : lundi 12 novembre 2018 14:10:50
À : pgsql-jdbc@lists.postgresql.org<mailto:pgsql-jdbc@lists.postgresql.org>
Objet : getAutocommit assertion error
Hello all,
in my java test case launched by maven I get the following exception:
java.lang.AssertionError: pgStatement.getConnection().getAutoCommit() should not throw
But I don't know why this error is returned ...
In my class, I set auto commit to 'false' value, and I commit at the ending like this:
try {
preparedStatement.close();
connection.commit();
} catch (SQLException e) {
log.error("Error while closing connection.", e.toString());
}
I check where the error comme from and I just found the following code, in BatchResultHandler:
private boolean isAutoCommit() {
try {
return pgStatement.getConnection().getAutoCommit();
} catch (SQLException e) {
assert false : "pgStatement.getConnection().getAutoCommit() should not throw";
return false;
}
}
I don't really understand the problem ...
anyone can help me please ?
Best regards,
Adrien
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-14 14:42 rob stone <floriparob@gmail.com>
parent: adrien ruffie <adriennolarsen@hotmail.fr>
1 sibling, 0 replies; 11+ messages in thread
From: rob stone @ 2018-11-14 14:42 UTC (permalink / raw)
To: adrien ruffie <adriennolarsen@hotmail.fr>; pgsql-jdbc@lists.postgresql.org <pgsql-jdbc@lists.postgresql.org>
Hello,
> > > private booleanisAutoCommit() {
> > > try {
> > > return pgStatement.getConnection().getAutoCommit();
> > > } catch (SQLException e) {
> > > assert false : "pgStatement.getConnection().getAutoCommit()
> > > should not throw";
> > > return false;
> > > }
> > > }
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: getAutocommit assertion error
@ 2018-11-14 15:59 jenca@lysator.liu.se
parent: adrien ruffie <adriennolarsen@hotmail.fr>
0 siblings, 0 replies; 11+ messages in thread
From: jenca@lysator.liu.se @ 2018-11-14 15:59 UTC (permalink / raw)
To: pgsql-jdbc@lists.postgresql.org
Hi again.
TL;DR: Adrien, either your code or your test framework are closing the
connection before where you see your failure, and you need to look
into that. I suggest you find and look at the stack trace for the
AssertionError.
I have checked out the code, looking at the 42.2.2 version with the
findings below.
1. I assume the assertion error is thrown from
org.postgresql.jdbc.BatchResultHandler, row 105:
101: private boolean isAutoCommit() {
102: try {
103: return pgStatement.getConnection().getAutoCommit();
104: } catch (SQLException e) {
105: assert false : "pgStatement.getConnection().getAutoCommit()
should not throw";
106: return false;
107: }
108: }
2. pgStatement is a org.postgresql.jdbc.PgStatement, and the method
getConnection() looks like:
871: public Connection getConnection() throws SQLException {
872: return connection;
873: }
3. The connection is a org.postgresql.core.BaseConnection, an
interface, with only one implementing class,
org.postgresql.jdbc.PgConnection, in this code base.
4. The method org.postgresql.jdbc.PgConnection.getAutoCommit() looks like:
727: public boolean getAutoCommit() throws SQLException {
728: checkClosed();
729: return this.autoCommit;
730: }
5. The method checkClosed() looks like:
765: protected void checkClosed() throws SQLException {
766: if (isClosed()) {
767: throw new PSQLException(GT.tr("This connection has been closed."),
768: PSQLState.CONNECTION_DOES_NOT_EXIST);
769: }
770: }
I am reasonable certain that the only way to trigger the assert in
BatchResultHandler is for checkClosed() to throw PSQLException. The
metod isClosed() calls
org.postgresql.core.QueryExecutorBase.isClosed() which do not throws
anything.
My conclusions is that...
- The problem is triggered by the connection being closed, which is a
problem that needs to looked at in the code under test.
- If the connection is closed, perhaps something other than an
AssertionError is better, which is something for the pgjdbc codebase.
Best regards,
///Jens Carlberg
Quoting adrien ruffie <adriennolarsen@hotmail.fr>:
> I changed it, but nothing works... same problem
>
> I am in despair.
>
> ________________________________
> De : Dave Cramer <pg@fastcrypt.com>
> Envoyé : mercredi 14 novembre 2018 14:33:40
> À : Adrien Ruffie
> Cc : pgsql-jdbc@lists.postgresql.org
> Objet : Re: getAutocommit assertion error
>
> Adrien,
>
> No reason not to use the latest
>
> 42.2.5
>
>
> Dave Cramer
>
> davec@postgresintl.com<mailto:davec@postgresintl.com>
> www.postgresintl.com<http://www.postgresintl.com;
>
>
> On Wed, 14 Nov 2018 at 08:32, adrien ruffie
> <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>> wrote:
>
> Sorry for this late anwser ...
>
> Dave, for the version of driver is:
>
>
> <groupId>org.postgresql</groupId>
> <artifactId>postgresql</artifactId>
> <version>42.2.2</version>
>
>
> Jens,
>
> I can't debug, because the problem only appears when bamboo lannched
> my test cases ... impossible to reproduce IDE and Maven command line
> ...
>
>
> ________________________________
> De : Jens Carlberg <jens.carlberg@gmail.com<mailto:jens.carlberg@gmail.com>>
> Envoyé : mardi 13 novembre 2018 10:11:32
> À : pgsql-jdbc@lists.postgresql.org<mailto:pgsql-jdbc@lists.postgresql.org>
> Objet : Re: getAutocommit assertion error
>
> After looking at the JDBC code, the only path I see leading to this
> error is if the connection has been closed. If nothing else, this
> might give you a clue where to look in your test code.
>
> Best Regards,
> ///Jens Carlberg
>
> On Tue, 13 Nov 2018 at 09:39, Jens Carlberg
> <jens.carlberg@gmail.com<mailto:jens.carlberg@gmail.com>> wrote:
> Hi.
>
> If you can, I suggest you run in debug and put a breakpoint in the
> method, so you can examine the thrown exception (or trace the call
> deeper). In Eclipse, it would be Run -> Debug As -> Maven Test
> (assuming this is when you run the tests). I have no experience in
> how to do this in other environment, but I assume other IDE:s at
> least have similar functionality. If you are using maven on the
> command line, this thread on StackOverflow might be helpful:
> https://stackoverflow.com/questions/2935375/debugging-in-maven
>
> Best Regards,
> ///Jens Carlberg
>
>
> On Tue, 13 Nov 2018 at 09:19, adrien ruffie
> <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>> wrote:
>
> Hello Dave,
>
> thank you for your advise, but unfortunately that not really change ...
> even by reversing the 2 lines, I still have the problem.
>
> It's very strange in source code
>
> private booleanisAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit()
> should not throw";
> return false;
> }
> }
>
>
> because you can't really see the really SQLException which should
> throws in order ot really debug the problem ...
> I have tried to find in postgres site, in jdbc driver topic and
> thread in internet but nothing :-(
>
>
> ________________________________
> De : adrien ruffie
> <adriennolarsen@hotmail.fr<mailto:adriennolarsen@hotmail.fr>>
> Envoyé : lundi 12 novembre 2018 14:10:50
> À : pgsql-jdbc@lists.postgresql.org<mailto:pgsql-jdbc@lists.postgresql.org>
> Objet : getAutocommit assertion error
>
>
> Hello all,
>
>
> in my java test case launched by maven I get the following exception:
>
>
> java.lang.AssertionError:
> pgStatement.getConnection().getAutoCommit() should not throw
>
>
> But I don't know why this error is returned ...
>
> In my class, I set auto commit to 'false' value, and I commit at the
> ending like this:
>
> try {
> preparedStatement.close();
> connection.commit();
> } catch (SQLException e) {
> log.error("Error while closing connection.", e.toString());
> }
>
>
> I check where the error comme from and I just found the following
> code, in BatchResultHandler:
>
>
> private boolean isAutoCommit() {
> try {
> return pgStatement.getConnection().getAutoCommit();
> } catch (SQLException e) {
> assert false : "pgStatement.getConnection().getAutoCommit()
> should not throw";
> return false;
> }
> }
>
>
>
>
> I don't really understand the problem ...
>
> anyone can help me please ?
>
>
> Best regards,
>
>
> Adrien
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2018-11-14 15:59 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 13:10 getAutocommit assertion error adrien ruffie <adriennolarsen@hotmail.fr>
2018-11-12 22:43 ` Dave Cramer <pg@fastcrypt.com>
2018-11-13 08:19 ` adrien ruffie <adriennolarsen@hotmail.fr>
2018-11-13 08:39 ` Jens Carlberg <jens.carlberg@gmail.com>
2018-11-13 09:11 ` Jens Carlberg <jens.carlberg@gmail.com>
2018-11-14 13:32 ` adrien ruffie <adriennolarsen@hotmail.fr>
2018-11-14 13:33 ` Dave Cramer <pg@fastcrypt.com>
2018-11-14 14:08 ` adrien ruffie <adriennolarsen@hotmail.fr>
2018-11-14 15:59 ` jenca@lysator.liu.se
2018-11-14 14:42 ` rob stone <floriparob@gmail.com>
2018-11-13 11:15 ` Dave Cramer <pg@fastcrypt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox