• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sqlite error

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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....
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved the problem:

thank's!!!

 
Acetylsalicylic acid is aspirin. This could be handy too:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic