?? sqlserverchargeruledao.java
字號:
package com.chinamobile.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.chinamobile.bean.ChargeRuleBean;
public class SQLServerChargeRuleDAO implements ChargeRuleDAO {
private final String INSERT_AN_CHARGERULE = "insert into TCharge_Rule values(?,?,?)";
private final String GET_AN_CHARGERULE = "select * from TCharge_Rule where Func_ID=?";
public boolean createChargeRule(ChargeRuleBean chargeRule) {
Connection conn =null;
PreparedStatement pstmt=null;
boolean tmp=true;
try{
conn=SQLServerDAOFactory.getConnection();
pstmt=conn.prepareStatement(INSERT_AN_CHARGERULE);
pstmt.setString(1, chargeRule.getFunc_ID());
pstmt.setString(2, chargeRule.getFunc_Name());
pstmt.setString(3, chargeRule.getCharge_Code());
int result=pstmt.executeUpdate();
if(result!=1)
tmp = false;
}catch(SQLException e){
tmp = false;
e.printStackTrace();
}finally{
SQLServerDAOFactory.closeStatement(pstmt);
SQLServerDAOFactory.closeConnection(conn);
}
return tmp;
}
public boolean isExists(ChargeRuleBean chargeRule) {
Connection conn =null;
PreparedStatement pstmt=null;
boolean tmp=true;
try{
conn=SQLServerDAOFactory.getConnection();
pstmt=conn.prepareStatement(GET_AN_CHARGERULE);
pstmt.setString(1, chargeRule.getFunc_ID());
ResultSet result=pstmt.executeQuery();
if(result.next()){
tmp = true;
}else{
tmp = false;
}
}catch(SQLException e){
e.printStackTrace();
}finally{
SQLServerDAOFactory.closeStatement(pstmt);
SQLServerDAOFactory.closeConnection(conn);
}
return tmp;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -