I'm trying to update a SQLite table with Java. This is the relevant part of the code:
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:test.db");
c.setAutoCommit(false);
System.out.println("Opened database successfully");
stmt = c.createStatement();
String sql = "INSERT INTO AMBROZIJA (LEVEL,DATE,TIME) " +
"VALUES ("+koncentracijaAmbrozije+","+date+","+time+");";
System.out.println(sql);
stmt.executeUpdate(sql);
stmt.close();
c.commit();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
System.out.println("Records created successfully");
When I run the code, I get the following output:
INSERT INTO AMBROZIJA (LEVEL,DATE,TIME) VALUES (6.5,2020-08-21,18:01:44.087078100);
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (near ":01": syntax error)
Process finished with exit code 0
The "near x" in (near ":01": syntax error)
part is from the minutes part of time so it changes with every execution.
How can I fix this error (I don't know much about SQLite)?