• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exceptions from getAutoCommit

 
Michael Phillips
Greenhorn
Posts: 3
IBM DB2 VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using MS JDBC, I can establish a connection, prepare a statement, execute the query, do "next" to no more data and close the result set. If I then try "getAutoCommit" it works fine, but if I try it after the doing a successful "isClosed" on the connection, the "getAutoCommit" throws an exception.

The same thing happens when I try "getAutoCommit" after a successful execution of a stored procedure.

What am I missing here? MTIA! -michael
 
Paul Clapham
Sheriff
Posts: 21548
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you close a connection, you can't reasonably expect to find out whether that connection used to support auto-commit before you closed it. In fact I don't even see why you're trying to do that. (Why are you calling getAutoCommit at random times anyway?)

But wait... you didn't actually say you closed the connection, did you?

At any rate, you didn't say what database driver you're using. That could be relevant information.
 
Michael Phillips
Greenhorn
Posts: 3
IBM DB2 VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,

Thanks for the reply!

No, I did not say that 'I closed the connection,' only that I closed the result set after doing an "executeQuery" and "next" on the result set until end of data; then a "getAutoCommit" works fine.

What I do not understand is why "getAutoCommit" fails immediately after making a connection.
The driver I am I using is 'com.microsoft.sqlserver.jdbc.SQLServerDriver' in 64-bit mode with AIX COBOL... (ok, I'm a dinosaur but code is code...

TIA! -michaelP
 
Michael Phillips
Greenhorn
Posts: 3
IBM DB2 VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Appears to be solved but not really sure why... the 'invoke "getAutoCommit"' was being done under multiple IF layers.
Moving to under just one IF seems to work but I do not understand why that would matter. Must some Java gotcha???
 
Paul Clapham
Sheriff
Posts: 21548
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what an "IF layer" is so I can't comment on that. But it's more likely to be a glitch in the JDBC driver than in Java itself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic