dao
protected Connection con = null;
protected PreparedStatement ps = null;
protected ResultSet rs = null;
/**
* 执行SQL语句
*
* @param strSql
* @author goupan
*/
public void executeSql(String strSql) {
try {
con = getConnection();
ps = con.prepareStatement(strSql);
ps.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
closeStatement();
closeConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 取得连接
*
* @return
*/
public Connection getConnection() {
return this.getSession().connection();
}
/**
* 关闭连接
*
* @throws Exception
*/
public void closeConnection() throws Exception {
if (con != null) {
con.close();
}
}
public void closeStatement() throws Exception {
if (ps != null) {
ps.close();
}
}
public void closeResultSet() throws Exception {
if (rs != null) {
rs.close();
}
}
/**
* 执行SQL语句
*
* @param strSql
* @author goupan
*/
public void executeSql(String strSql) {
try {
con = getConnection();
ps = con.prepareStatement(strSql);
ps.execute();
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
closeStatement();
closeConnection();
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 取得连接
*
* @return
*/
public Connection getConnection() {
return this.getSession().connection();
}
/**
* 关闭连接
*
* @throws Exception
*/
public void closeConnection() throws Exception {
if (con != null) {
con.close();
}
}
public void closeStatement() throws Exception {
if (ps != null) {
ps.close();
}
}
public void closeResultSet() throws Exception {
if (rs != null) {
rs.close();
}
}