JDBC编程
(1)分页查询
limit [位置偏移量】,行数
(2)提取工具类
public class JDBCUtils {
public static final String connenctionURL="jdbc:mysql://localhost:3306/web01?useUnicode=true&characterEncoding=UTF8&serverTimezone=UTC";
public static final String username="root";
public static final String password="root";
//得到链接
public Connection getConnection() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");//一般不会变,url和con可能会变
return DriverManager.getConnection(url,username,password);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public void close(ResultSet rs,Statement stmt,Connection con) {
try {
if(rs!=null)rs.close();
if(stmt!=null)rs.close();
if(con!&