📄 modeltoroesdao.java
字号:
package com.accp.oa.dao.imple;
import java.util.ArrayList;
import com.accp.oa.common.Constants;
import com.accp.oa.common.DbUtil;
import com.accp.oa.dao.inface.*;
import com.accp.oa.bean.*;
import java.sql.*;
/*
* 此类用于对表tb_model_roes
* 进行相应的操作
*/
public class ModelToRoesDAO implements BaseDAO {
private Connection con;
private PreparedStatement stmt ;
public ModelToRoesDAO() {
if(con == null){
try{
con = DbUtil.connectToDB();
con.setAutoCommit(false);//设为手动提交
}catch(Exception ex){
}
}
}
/*
* 提交事务
*/
public boolean commit(){
try {
con.commit();
} catch (SQLException e) {
return false;
}
return true;
}
/*
*回滚事务
*/
public void rollback(){
try {
con.rollback();
} catch (SQLException e) {
}
}
/*
* 此方法用于关闭连接
*/
public void CloseConnection(){
if (con != null)
try {
con.close();
} catch (SQLException e) {
}
}
/*
* 此类用于关闭PrepareStatement
*/
public void ClosePrepareStatement(){
if(stmt != null)
try {
stmt.close();
} catch (SQLException e) {
}
}
/*
* 此方法用于添加表中的数据
* @see com.accp.oa.dao.inface.BaseDAO#add(java.lang.Object)
*/
public boolean add(Object modelToRoes) {
ModelToRoes modeltoroes = (ModelToRoes)modelToRoes;
try {
stmt = con.prepareStatement(Constants.GRAND_RIGHT_ROES);
stmt.setInt(1, modeltoroes.getModelId());
stmt.setInt(2, modeltoroes.getRoesId());
stmt.executeUpdate();
} catch (SQLException e) {
return false;
}
return true;
}
public boolean delete(Object obj) {
return false;
}
/*
* 此方法用于删除表中的数据
* @see com.accp.oa.dao.inface.BaseDAO#delete(int)
*/
public boolean delete(int id) {
try{
stmt = con.prepareStatement(Constants.DELETE_MODEL_ROES);
stmt.setInt(1, id);
stmt.executeUpdate();
}catch(Exception ex){
return false;
}
return true;
}
public boolean delete(String ag0) {
return false;
}
public Object search(Object obj) {
return null;
}
public int search(String ag0, String ag1) {
return 0;
}
public Object search(int id) {
return null;
}
public ArrayList search(String age0) {
return null;
}
public ArrayList search(int ag0, int age1) {
return null;
}
public ArrayList search() {
return null;
}
public boolean update(Object obj) {
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -