SQLite error in Java not reproducible elsewhere
The java application I am working with uses local SQLite databases for specific data using https://bitbucket.org/xerial/sqlite-jdbc version 3.8.10.2.
I am parsing data from an Excel spreadsheet and inserting it into a database. The query 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 am doing this is because I am inserting multiple lines at once (approximately 1475). Before running the update, I am outputting it through the console, so I have a completed request in my hands.
Running it through java throws this exception:
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ",": syntax error)
However, I also use this application http://sqlitebrowser.org/ to manually monitor the database. By using the "Execute SQL" function in the specified application, the query I am building with my code works and the table is populated correctly.
What can make the update request work in the specified application rather than when it is launched from a java application?
source to share
No one has answered this question yet
See similar questions:
or similar: