java - H2: executeBatch doesn't work -


i have following code

string query = "insert student (age,name) values (?,?)"; conn.setautocommit(true);   ps = conn.preparestatement(query);             (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. table student empty. use h2 1.3.176 in embedded mode. wrong?

you forgot add batch set of parameters:

string query = "insert student (age,name) values (?,?)"; conn.setautocommit(true);   ps = conn.preparestatement(query);             (student student:list) {     ps.setint(1, student.getage());     ps.setstring(2, student.getname());     ps.addbatch(); // <-- } int[]temp=ps.executebatch(); system.out.println("temp:"+temp.length); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -