标签:har public for sql语句 print odi encoding 结果 prepare
public class BaseDao {
/** 连接 */
protected Connection con;
/** SQL语句对象 */
protected PreparedStatement ps;
/** 结果集合对象 */
protected ResultSet rs;
/**
* 建立连接
*/
public void setConnection() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/myweb(数据库名字)?characterEncoding=utf-8", "root",
"123456");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 关闭连接
*/
public void closeConnection() {
try {
if (rs != null) {
rs.close();
}
if (ps != null) {
ps.close();
}
if (con != null) {
con.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
标签:har public for sql语句 print odi encoding 结果 prepare
原文地址:https://www.cnblogs.com/wind-copy1234/p/11793964.html