I have the following code
String query = "INSERT INTO student (age,name) VALUES (?,?)";
conn.setAutoCommit(true);
ps = conn.prepareStatement(query);
for (Student student:list) {
ps.setInt(1, student.getAge());
ps.setString(2, student.getName());
}
int[]temp=ps.executeBatch();
System.out.println("TEMP:"+temp.length);//returns 0
The code executed. No errors no exceptions. However table student is empty. I use h2 1.3.176 in embedded mode. What is wrong?
You forgot to add batch set of parameters: