
1.连接数据库。使用查询功能
//1.获取数据库连接
Connection con=JDBCTools.getConnection();
String sql="select * from userinfo where username='"+username+"'";
//2.获取SQL语句执行者对象
PreparedStatement pst=con.prepareStatement(sql);
//3.执行SQL语句,并得到结果集(使用的是查询功能)
ResultSet rs=pst.executeQuery();
2.连接数据库,并清空数据库表
//1.获取数据库连接
Connection con=JDBCTools.getConnection(); //注意:调用类的静态方法只需要通过类名直接调用
String sql = "Truncate Table jufaanalyze"; //清空表中的所有数据
//2.获取SQL语句执行者对象
PreparedStatement pst=con.prepareStatement(sql);
//3.执行SQL语句,并得到结果集
pst.executeUpdate();