Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: Invalid Transaction State

 
rahul kumar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before i switch over to my problem let megive u brief description of the way i am handling JDBC connection.
I am using jdbc odbc bridge with MS SQL Server 7.0 and jdk1.4 ,a single Connection object and Statement object throughout the project is being used but i also create new Statement objects where it is necessary to get data from two or more than two ResultSet.
This exception (SQLException: Invalid transaction state) comes when i close the main frame of my application where i am trying to close the connection.
What i want to know is what are the reasons due to which this exception can occur and what are the possible solutions to it.
i will be thankfull to u all if u reply soon as i have to submit my project on this 31.
 
rahul kumar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its my humble request to u all pls suggest the solution to my problem as i am running out of time.
 
Dakshinamurthy Ramachandran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, just check your code for the following.
If you opened the connection as con.setAutoCommit(false), then make sure you call either con.commit() or con.rollback().
Best of luck !!!
 
rahul kumar
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ramachandran for ur help .what u told is already part of my code ie. i commit()on successful execution of query and rollback on Exception but i will check for the case where i might have forget to do that thing.
 
Pablo Bruno
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
have you tried a connection.setAutocommit (true) before de close of the connection?
i remember it happened to me with jre 1.4.0. Have you tried jre 1.4.2?
I think it might be a jdbc-odbc bridge issue.

Pablo
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul,
I think that if you post the entire error message and stack trace you are getting, as well as the section of your code that is causing the error, I may be able to help you further.

From my experience, error messages can sometimes be misleading. Hence the problem may not directly be due to some transaction problem.

In any case, I believe it is best to use the JDBC driver that is most suitable to the database you are using. The JDBC-ODBC bridge driver is not the most suitable (in my opinion). Although I don't use "SQL Server", I am sure that there are "SQL Server" specific JDBC drivers available. Have you tried searching (the Internet) for them?

Good Luck,
Avi.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic