A java application I am working on uses local SQLite databases for certain data, using https://bitbucket.org/xerial/sqlite-jdbc version 3.8.10.2.
I parse data from an excel spreadsheet and then insert into the database. The request is built as such:
String request = "INSERT INTO 'table' ('col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8', 'col9', 'col10') VALUES";
for(Data d : dataToInsert){
request += " ('" + d.getCol1().replaceAll("'", "''") +"', '" + d.getCol2().replaceAll("'", "''") +"', '" + d.getCol3().replaceAll("'", "''") +"', '" + d.getCol4().replaceAll("'", "''") +"', '" + d.getCol5().replaceAll("'", "''") +"', '" + d.getCol6().replaceAll("'", "''") +"', '" + d.getCol7().replaceAll("'", "''") +"', '" + d.getCol8().replaceAll("'", "''") +"', '" + d.getCol9().replaceAll("'", "''") +"', '" + d.getCol10().replaceAll("'", "''") +"'),";
}
request = request .substring(0, request .length()-1) + ";";
The reason I do it this way is because I am inserting a large number of rows at once (approx 1475). Before running the update, I have it outputted via console so I have the completed request in my hands.
Running it via java causes this exception:
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ",": syntax error)
However, I am also using this app http://sqlitebrowser.org/ to monitor the database manually. Using the "Execute SQL" function in said app, the request I build with my code works, and the table is populated correctly.
What could cause the update request to work in said app and not when ran from the java application?