zoukankan      html  css  js  c++  java
  • 最简单的jdbc操作

     1 Connection con = null;
     2         Statement stmt = null;
     3         
     4         // 保存到表中
     5         String sql = "insert into website(username,userpassw) values('喜欢','不喜欢')";
     6         
     7         try {
     8             Class.forName("com.mysql.jdbc.Driver");
     9             //链接对象
    10             con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/mysqlconnect", "root", "bequt");
    11             //执行命令对象
    12             stmt = con.createStatement();
    13             //执行
    14             stmt.execute(sql);
    15             //关闭
    16             stmt.close();
    17             con.close();
    18         } catch (Exception e) {
    19             // TODO Auto-generated catch block
    20             e.printStackTrace();
    21         }
  • 相关阅读:
    Fire
    Apple Tree
    访问艺术馆
    三角关系
    字母表
    折纸
    旅行
    单词分类

    圆桌游戏
  • 原文地址:https://www.cnblogs.com/bequt/p/6188177.html
Copyright © 2011-2022 走看看