“jdbc:mysql://localhost:3306/mydb?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8”,
“root”,
“123456”);
//4.使用Statement执行操作
// //4.1定义SQL语句
// String sql=“select * from student”;
// //4.2获取SQL的对象
// stmt=conn.createStatement();
// //4.3执行SQL
// rs=stmt.executeQuery(sql);
//4.使用PreparedStatement执行操作
//4.1获取SQL的对象
pstm =conn.prepareStatement(“select * from student”);
//4.2执行SQL,得到结果
rs=pstm.executeQuery();
//5.处理结果
while(rs.next()){
System.out.print(rs.getString(“name”)+" ");
}
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
try {
//6.释放资源
if(rs!=null)rs.close();
if(stmt!=null)stmt.close();
if(pstm!=null)stmt.close()