I have a table in sqlite (in java), it has 3 columns the ID is autoicremented.
stat.executeUpdate("create table Info (ID INTEGER PRIMARY KEY AUTOINCREMENT, age int, point int);");
when I want to insert in that table I have this function
DataBase.databaseInsertInfoTable(data.age, data.point);
and
public static void databaseInfoTable(int age,int point) throws Exception {
PreparedStatement prepInfo = conn.prepareStatement(
"insert into Info (age, point)values (?, ?);");
prepInfo.setInt(2, age);
prepInfo.setInt(3, point);
prepInfo.addBatch();
prepInfo.executeBatch();
conn.setAutoCommit(true);
prepInfo.close();
}
I have an error which says bad parameter I wanted to insert null value for ID but it does not work too so I omit the ID in insertion! what should I do?
You can’t insert a null value for an AUTOINCREMENT field. Remove the semi-colon at the end of the statement and see if that works for you.
EDIT: try this.