JDBC数据库删除

 1  //删除操作:
 2      
 3      if(conn != null){
 4          String temps="2";
 5          conn.setAutoCommit(false);
 6          PreparedStatement preparedStatement = conn.prepareStatement(SQL_USER_DELETE);
 7          preparedStatement.setString(1,temps);
 8          int line =preparedStatement.executeUpdate();
 9          conn.commit();
10          if(line>0)
11              out.print("删除了"+line+"条数据!");
12          preparedStatement.close();
13  }
14      //修改操作
15      if(conn != null){
16          
17          String temp1="3";
18          conn.setAutoCommit(false);
19          PreparedStatement preparedStatement = conn.prepareStatement(SQL_USER_MODIFY);
20          preparedStatement.setString(1,"我就修改!");
21          preparedStatement.setString(2,temp1);
22          int line = preparedStatement.executeUpdate();
23          conn.commit();
24            if(line>0){
25                out.print("修改了"+line+"条数据!");
26            }
27            preparedStatement.close();
28      }

 

posted @ 2020-11-02 23:03  靠谱杨  阅读(201)  评论(0编辑  收藏  举报