Cecil Westerhof

Greenhorn
+ Follow
since Jul 05, 2011
Cecil likes ...
Netbeans IDE Suse Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cecil Westerhof

Madhan Sundararajan Devaki wrote:I believe, one possible reason could be, the preparedstatement object could be in an inconsistent state after an exception and is being prevented from being executed.


Okay, when doing the prep = conn.prepareStatement again, there is no problem. But this still leaves me with my real problem. I did get the "statement is not executing" after inserting a little more as 2.000 records. The way I 'solved' it was by not inserting more as a 1.000 records pro program run. Now I do the prep = conn.prepareStatement again every 1000 inserts. But why is this necessary?

Madhan Sundararajan Devaki wrote:From your CREATE TABLE statement I observe that the name column is Unique! This will prevent subsequent inserts with same value!


The problem is not that I can not insert the same twice (that I am doing on purpose to show the problem), the problem is that after the exception isgenerated, the statement setSting generates an exception "statement is not executing".

Scott Selikoff wrote:Although it shouldn't be necessary, have you tried setting the values again before executing the query? It's possible that driver doesn't retain them. Also the code "catch (Exception e) {}" is a bad practice. You should always handle your exceptions.



I did not, but that is not the problem, because this is only to show the problem. To be really sure I changed the code:


Still the same problem.

Also in my real program I handle the exception. Here I am just generating the exception to show the problem.
The following code works:


I use it with the jar I got from:
www.xerial.org/trac/Xerial/wiki/SQLiteJDBC

When I remove the comment and try to insert the first record two times, I get the following error with the next setString:


This is just to show the problem. I hit on the problem when inserting more as 2000 records, but this is a little easier to demonstrate. ;-)

What is happening here and how to solve it?