⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlserverchargeruledao.java

📁 中国移动管理系统
💻 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 + -