This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

SQLException: Invalid Transaction State

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic