zoukankan      html  css  js  c++  java
  • 增,删,改

    public static void main(String[] args) throws ClassNotFoundException, SQLException  {
    14         String URL="jdbc:mysql://127.0.0.1:3306/imooc?useUnicode=true&characterEncoding=utf-8";
    15         String USER="root";
    16         String PASSWORD="tiger";
    17         //1.加载驱动程序
    18         Class.forName("com.mysql.jdbc.Driver");
    19         //2.获得数据库链接
    20         Connection conn=DriverManager.getConnection(URL, USER, PASSWORD);
    21         //3.通过数据库的连接操作数据库,实现增删改查(使用Statement类)
    22         String s=""+"insert into user(id,user_name,user_password) values("+"2,?,123)";
    23         PreparedStatement pst=conn.prepareStatement(s);
    24         
    25         pst.setString(1, "xiaoshuai1");
    26         //pst.setString(2, "123");
    27             
    28         pst.execute();        
    29         //关闭资源        
    30         pst.close();
    31         conn.close();
    32     }
  • 相关阅读:
    P3811乘法逆元
    P4549裴蜀定理
    备用代码区
    其他板子整理
    DP
    图论板子整理
    约数
    浅谈假学习假努力
    质数
    P1019 单词接龙
  • 原文地址:https://www.cnblogs.com/liuqu/p/8658303.html
Copyright © 2011-2022 走看看