Note that there are some explanatory texts on larger screens.

plurals
  1. POJava - MySQL --> SQLite - unable to insert in SQLite database using java
    text
    copied!<p>iv created a program which works really well with MySQL. However, when I convert it to SQLlite, everything works such as Creating tables, getConnection() to the database and such EXCEPT inserting values to the table?? I am unable to insert value to the table using Java (Netbeans) to SQLite database. I can only insert ONE row but not multiple rows? In MySQL, i could insert multiple rows at once, however, I cant in SQLite? </p> <p>The code is (This works for only ONE row):</p> <pre><code> Connection con; Statement s= con.CreateStatement(); String st = "Insert into table1 (10,'abc')"; s.executeUpdate(st); s.close(); </code></pre> <p>If I do something like this (DOES NOT work for more than one row - have no idea why- SQLite):</p> <pre><code> Connection con; Statement s= con.CreateStatement(); String st = "Insert into table1 (10,'abc'), (5,'vfvdv')"; //now it doesnt work since Im inserting more than one row. I can't figure out what Im doing wrong - //Iv also tried Insert into table1(ID, Name) values (10,'abc'), (5,'afb'); but it dont work. s.executeUpdate(st); s.close(); </code></pre> <p>Could any java expert or anyone help me on this. I cant figure out what Im doing wrong or anything because when I type my commands in the 'SQLite' command line it works fine for ALL. But, In JAVA with SQLite, I can only update one row for some reason? However, Java with MySQL works fine but not SQLlite.</p> <p>Anyone could clarify what Im doing wrong would be brillant. Thanks alot for reading this and your time.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload