JDBC API入门

 时间:2024-10-13 23:41:01

1、导包在eclipse工程名下穿件lib文件夹并把jar包放入,右键buildpath即可

2、加载驱动:Class.forName("com.mysql.jdbc.Driver");3,获得连接多唉捋胝:Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123");括号中三个分别为:url,数据库用户名,密码;

3、获得SQL语句对象:Statement statement= conn.createStatement();5,执行SQL语句:ResultSet rs= statement.executeQuery("select * from exam");

4、遍历结果: while(rs.next()) {System.out.print(rs.getInt("id")+" "稆糨孝汶;);System.out.print(rs.getString("name")+" ");System.out.print(rs.getInt("english")+" ");System.out.print(rs.getInt("chinese")+" ");System.out.print(rs.getInt("math")+" ");System.out.println();}

  • jdbc怎么使用?
  • JDBC怎么insert
  • Eclipse通过JDBC连接MYSQL
  • JDBC怎么连接MySQL
  • 热门搜索
    ps怎么放大图片 淘宝店铺怎么装修 干竹笋怎么做好吃 电脑mac地址怎么查 冬瓜排骨汤怎么做 颐莲化妆品怎么样 胸小怎么办 树懒怎么读 孕妇胃胀气怎么办 盛字五笔怎么打