wood burning stoves*
The moose likes JDBC and the fly likes Sqlite error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Sqlite error" Watch "Sqlite error" New topic
Author

Sqlite error

paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86
i have copy my program with database...from mysql to sqlite...

it's all ok but when i want inset data i have error:

Error: cannot commit transaction - SQL statements in progress

this is code:



in mysql it's all ok in sqlite i have this problem....

help me please...i don't understand this problem....
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2232
    
  47
I've never used SQLite so don't know if the following points have any bearing on your problem:

1. The point of prepared statements is you "make them once and use them many times" so you should create the prepared statements outside the loops
2. Your select statement is never closed as you reuse the pstmt variable in the result set loop. Similarly all the statements created in the result set loop, except for the last one, will never be closed.
3. ResultSets are only automatically closed if the statement that generated them is closed or re-executed. Most of your statements are never closed and none are re-executed so you aren't closing most of the ResultSets.
4. Statements should be closed in a finally clause to make sure they are always closed.
paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86
the problem is in ResultSet...

i have try to delete rs = pstmt.executeQuery(); no error...but don't insert nothing....

how to edit???

paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86
you write me...

Statements should be closed in a finally clause to make sure they are always closed.

how to close??? where???

in this frame i can to do multiselect......
paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86
i edit script....

the select with Statement and insert with PreparedStatement

but i have equals problem

i'm sure the proble is in resultset....

this is code:

Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2232
    
  47
You probably need to do what I said in my earlier post ie make sure you close every statements object you create.

The best thing is to move your create prepared statements code outside of the loops, assign them to separate variables, add a finally clause to your inner try statement and call close() on both statement variables in the finally clause.
paul beppe
Ranch Hand

Joined: Aug 09, 2012
Posts: 86
I solved the problem:

thank's!!!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sqlite error