public static void main(String[] args) {Renewal c = new Renewal(); // 创建本类对象con = c.getConnection(); // 调用连接数据库方法try {sql = con.prepareStatement("select * from tb_stu"); // 查询数据库res = sql.executeQuery(); // 执行SQL语句System.out.println("执行增加、修改、删除前数据:");while (res.next()) {String id = res.getString(1);String name = res.getString("name");String sex = res.getString("sex");String birthday = res.getString("birthday"); // 遍历查询结果集System.out.print("编号:" + id);System.out.print(" 姓名:" + name);System.out.print(" 性别:" + sex);System.out.println(" 生日:" + birthday);}sql = con.prepareStatement("insert into tb_stu(name,sex,birthday) values(?,?,?)");sql.setString(1, "阿杰"); // 预处理添加数据sql.setString(2, "男");sql.setString(3, "2001-03-08");sql.executeUpdate();sql = con.prepareStatement("update tb_stu set birthday "+ "= ? where id = ? ");sql.setString(1, "2012-12-02"); // 更新数据sql.setInt(2, 1); // 更新数据sql.executeUpdate();Statement stmt = con.createStatement();stmt.executeUpdate("delete from tb_stu where id = 9");//删除// 查询修改数据后的tb_stu表中数据sql = con.prepareStatement("select * from tb_stu");res = sql.executeQuery(); // 执行SQL语句System.out.println("执行增加、修改、删除后的数据:");while (res.next()) {String id = res.getString(1);String name = res.getString("name");String sex = res.getString("sex");String birthday = res.getString("birthday");System.out.print("编号:" + id);System.out.print(" 姓名:" + name);System.out.print(" 性别:" + sex);System.out.println(" 生日:" + birthday);}} catch (Exception e) {e.printStackTrace();}}}