hi guys,
iam workin on an application that calculate the income for certain diving centers, i using the SQLite database, i developed a database with 3 table the first one for user input, the second is to hold daily income, and the third for weekly income.

i've a problem when i'm trying to write in the second table the income after each user input, here's the exception when i'm using the Statement object

stmnt.execute("UPDATE dailyIncome SET Credit_NIS = '"+nis+"'");

java.sql.SQLException: database locked
at org.sqlite.DB.execute(DB.java:270)
at org.sqlite.Stmt.exec(Stmt.java:56)
at org.sqlite.Stmt.execute(Stmt.java:83)

and the following one is when i'm using the prepared statement

PreparedStatement pre = con.prepareStatement("UPDATE dailyIncome SET Credit_NIS = ? WHERE Date_PK = ?");

java.sql.SQLException: cannot commit transaction - SQL statements in progress
at org.sqlite.DB.throwex(DB.java:288)
at org.sqlite.DB.ensureAutoCommit(DB.java:336)
at org.sqlite.DB.execute(DB.java:264)
at org.sqlite.DB.executeUpdate(DB.java:281)
at org.sqlite.PrepStmt.executeUpdate(PrepStmt.java:77)


i need to know why this problem occured and how to solve it???

Thanks in advance.

Do not create exact duplicate posts for the same question. You already posted this 2 days ago.

The errors are most likely a result of incomplete operations you have started and not finished elsewhere against the database, such as transactions you haven't committed. You'll have to check those things yourself, because those statements that you posted provide no clue as to where the problem is occurring.

The problem occur when you trying to query a table to get some result and process that data after that writing to another table i don't why it can't complete or why the database is locked???
is there's any solution for that??

> i need to know why this problem occured and how to solve it???

Post the relevant code snippets. Are you sure you are releasing the database resources after performing the read/write?

Are you working with the database using the sqlite console and at the same time trying to query/insert into that database via your program? If yes, then try closing the console / sqlite process which uses the same file and then try again.

We need some code to figure out exactly what is going wrong.

You need close the ResultSet on allways queries

Thanks Dinho Pereira, that worked for me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.