@Test
/**
*
*/
public void demo2(){
Connection conn = null;
PreparedStatement pstmt = null;
try{
// :
conn = JDBCUtils.getConnection();
// SQL :
String sql = "update user set username = ?,password =?,nickname=?,age = ? where id = ?";
// SQL:
pstmt = conn.prepareStatement(sql);
// :
pstmt.setString(1, "abc");
pstmt.setString(2, "1234");
pstmt.setString(3, " ");
pstmt.setInt(4, 23);
pstmt.setInt(5, 6);
// SQL:
int num = pstmt.executeUpdate();
if(num > 0){
System.out.println(" !");
}
}catch(Exception e){
e.printStackTrace();
}finally{
JDBCUtils.release(pstmt, conn);
}
}