JDBC API入门

 时间:2025-10-23 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
  • 热门搜索
    suv是什么 果儿是什么意思 一花一世界一叶一菩提是什么意思 经常头痛是什么原因 融券卖出是什么意思 京东用什么支付 什么是气质 brush是什么意思 杰出的反义词是什么 软件是什么