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();

 

相关文章:

  • 2022-01-11
  • 2022-12-23
  • 2021-05-20
  • 2021-12-22
  • 2022-12-23
  • 2021-08-19
  • 2021-09-25
  • 2021-11-14
猜你喜欢
  • 2021-09-03
  • 2021-07-22
  • 2021-12-09
  • 2021-08-17
  • 2022-12-23
  • 2021-07-04
  • 2021-06-03
相关资源
相似解决方案