Hi, With autocommit disabled, I think there should be no gaps, but now thinking about it again I'm not completely sure. It's probably best if you test it.
Regards, Thomas On Friday, June 12, 2015, iJava <[email protected]> wrote: > Ok. Will the following code guarantee 100% that there won't be any id gaps > when H2 is server (there are other clients)? > > Connection conn= getting connection from pool > conn.setAutoCommit(false); > ps = > conn.prepareStatement(query,Statement.RETURN_GENERATED_KEYS); > for (Answer answer:list) { > ps.setInt(1, answer.getTaskId()); > ps.setString(2, answer.getText()); > ps.setInt(3, answer.getOrder()); > if (answer.getGroupKey()!=null){ > ps.setString(4,answer.getGroupKey()); > }else{ > ps.setNull(4, java.sql.Types.VARCHAR); > } > ps.setInt(5, answer.getScore()); > ps.addBatch(); > } > int[]temp=ps.executeBatch(); > conn.commit(); > conn.setAutoCommit(true); > conn.close(); > > > -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','h2-database%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
