int snap_id = 0;
ResultSet rs = null;
try (Connection connection = new DataSourceConnection().getConnection();
PreparedStatement ps = connection.prepareStatement(
"INSERT INTO snap (snap_id,endtime) VALUES (NULL,NULL)",
PreparedStatement.RETURN_GENERATED_KEYS)) {
ps.executeUpdate();
rs = ps.getGeneratedKeys();
while (rs.next()) {
snap_id = rs.getInt(1);
}
} catch (ClassNotFoundException | SQLException e) {
System.out.println(e);
}
System.out.println("snap_id : " + snap_id);