No, probably because the JDBC specification does not require getGeneratedKeys to work with executeBatch() , as indicated here . If your driver supports it, you need to use plain old JDBC to access the result set. The code would be something like this:
PreparedStatement ps = conn.prepareStatement("insert into ... values (?)", Statement.RETURN_GENERATED_KEYS); ps.setXXX(1, value1); ps.addBatch(); ps.setXXX(1, value2); ps.addBatch(); ps.executeUpdate(); ResultSet rs = ps.getGeneratedKeys();
source share