Best practices for using sqlite for a database queue

I am using sqlite database for a lineup of consumer producers.

One or more producers INSERT one line at a time with a new automatic incremental primary key.

There is one consumer (implemented in java, uses the sqlite-jdbc library ), and I want it to read a batch of rows and delete them. It sounds like I need transactions for this, but trying to use SQLite with transactions seems wrong. Can I say this?

If I really need transactions, what's the right way to do this in Java?

 Connection conn;
 // assign here

 boolean success = false;
 try {
    // do stuff
    success = true;
 }
 finally
 {
    if (success)
       conn.commit();
    else
       conn.rollback();
 }
+3
source share
2 answers

SQLite (!) . , - " ", , , Java , .

, ( ).

+1

. Java JDBC.

, , , . - , , . , , , . (, ), .

+2

Source: https://habr.com/ru/post/1721188/


All Articles