能更改成功,但是返回值一直是1,在后面的判断中起了很大的问题
dbutil
private static String driver = "com.mysql.jdbc.Driver";
private static String url = "jdbc:mysql://localhost:3306/on?useUnicode=true&characterEncoding=utf-8&useAffectRows=true";
private static String user = "root";
private static String password = "123456";
public int userState(int n) {
int count = -1;
String sql = "UPDATE system SET userstate=? WHERE id='1'";
Connection conn = null;
PreparedStatement pstmt = null;
conn = DBUtil.getConn();
try {
pstmt = conn.prepareStatement(sql);
pstmt.setObject(1, n);
count = pstmt.executeUpdate();
} catch (Exception e) {
// TODO: handle exception
}finally{
DBUtil.closeAll(conn, pstmt, null);
}
return count;
}