I have a PreparedStatement with a MySQL query that deletes rows based on a timestamp criteria. Is it possible to pull out how many rows were deleted from that same delete prepared statement or would I have to run a separate query to get the number first? This is what I tried but it didn't work:
PreparedStatement pstmt = conn.prepareStatement(delete, PreparedStatement.RETURN_GENERATED_KEYS);
pstmt.setString(1, keyword);
pstmt.executeUpdate();
ResultSet rs = pstmt.getGeneratedKeys();
while (rs.next())
{
n = rs.getInt(1);
}
rs.close();
pstmt.close();
conn.close();
Sorry guys, I figured it out. int n = pstmt.executeUpdate();