c = datasource.getConnection();
ps = c.prepareStatement(statement);
setup(ps);
int rows = ps.executeUpdate();
if (rows != 1) {
throw new AvroBaseException("inserted wrong number of rows: " + rows);
}
ps2 = c.prepareStatement("SELECT LAST_INSERT_ID()");
rs2 = ps2.executeQuery();
if (rs2.next()) {
return rs2.getInt(1);
} else {
throw new AvroBaseException("unexpected response");
}
} finally {
if (rs2 != null) rs2.close();
if (ps2 != null) ps2.close();
if (ps != null) ps.close();
if (c != null) c.close();
}
} catch (SQLException e) {
throw new AvroBaseException("Database problem", e);
}
}