时间:2021-07-01 10:21:17 帮助过:26人阅读
ResultSet rs = null; PreparedStatement ps = null; String sql = "select * from think_user;"; try { ps = conn.prepareStatement(sql); rs = ps.executeQuery(); while (rs.next()) { System.out.println(rs.getString("id")); System.out.println(rs.getString("username")); System.out.println(rs.getString("turename")); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }
最后一定要记得 关闭链接哦!!
最简单的一个java驱动jdbc链接mysql数据库
标签:statement exception query dstat select com div ack tac