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

📄 infodao.java

📁 一个很不错的移动业务简单业务支撑系统
💻 JAVA
字号:
package com.oristand.dao;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

import com.oristand.service.AccountBean;
import com.oristand.service.CustomerBean;
import com.oristand.service.OperatorBean;

public class InfoDao {
	
	Connection con=null;
	Statement st=null;
	ResultSet rs=null;
    public int findOperator(String sql){
		con=ConnectionMgr.getConnection();
		int count=0;
		try {
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				count=rs.getInt(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
		
    	return count;
    }
    public String FindInfo(String sql){
    	con=ConnectionMgr.getConnection();
	    String result="";
		try {
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				result=rs.getString(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
    	return result;
    }
    
    
    public  int Check(String sql){
    	int count=0;
    	con=ConnectionMgr.getConnection();
		try {
			st=con.createStatement();
			rs=st.executeQuery(sql);
			
			while(rs.next()){
				count=rs.getInt(1);
			}
			//System.out.println("check++++++++++++++++++"+count);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
		
    	return count;
    }
    public int Update(String sql){
    	int count=0;
    	con=ConnectionMgr.getConnection();
    	try {
    		System.out.println("Update=================="+sql);
			st=con.createStatement();
			count=st.executeUpdate(sql);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			 ConnectionMgr.freeResource(con, st, null);
		}
    	return count;
    }
    public String[] getCharge(String sql){
    	String[] charge= new String[5];
    	
        int i=0;
    	try {
    		con=ConnectionMgr.getConnection();
			st=con.createStatement();
			rs=st.executeQuery(sql);
			System.out.println(sql);
			while(rs.next()){
				charge[i]=rs.getString(1); 
				i++;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
    	
    	return charge;
    }
    public List findCustomerList(String sql){
    	List list=new ArrayList();
    	CustomerBean customer= new CustomerBean();
    	try {
    		con=ConnectionMgr.getConnection();
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				customer.setCustomer_ID(rs.getString(1));
				customer.setID_Type(rs.getString(2));
				customer.setID_Number(rs.getString(3));
				customer.setCustomer_Name(rs.getString(4));
				customer.setCustomer_Birthday(rs.getString(5));
				customer.setCustomer_Sex(rs.getString(6));
				customer.setCustomer_Address(rs.getString(7));
				list.add(customer);
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
    	
    	 return list;
    }
    public String findCustomer_ID(String sql){
    	con=ConnectionMgr.getConnection();
    	String Customer_ID="";
		try {
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				Customer_ID=rs.getString(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return Customer_ID;
    }
    public List findList(String sql){
    	List list=new ArrayList();
    	try{
    		con=ConnectionMgr.getConnection();
    		st=con.createStatement();
    		rs=st.executeQuery(sql);
    		System.out.println("--------------------"+sql);
    		while(rs.next()){
    			list.add(rs.getString(1));
    		}
    		
    	}catch(Exception e){
    		e.printStackTrace();
    	}finally{
    		ConnectionMgr.freeResource(con, st, rs);
    	}
    	
    	return list;
    }
	public List findAccountList(String sql) {
		List list=new ArrayList();
		AccountBean account=new AccountBean();
		try{
			con=ConnectionMgr.getConnection();
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				account.setAccount_ID(rs.getString(1));
				account.setContact_Person(rs.getString(2));
				account.setContact_Address(rs.getString(3));
				account.setAccount_Balance(rs.getString(4));
				list.add(account);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		return list;
	}
	public List findOperatorList(String sql){
		List list=new ArrayList();
		
		try{
			con=ConnectionMgr.getConnection();
			st=con.createStatement();
			rs=st.executeQuery(sql);
			while(rs.next()){
				OperatorBean operator =new OperatorBean();
				operator.setOperator_ID(rs.getString(1));
				operator.setOperator_Name(rs.getString(2));
				operator.setOperator_Pwd(rs.getString(3));
				operator.setIs_Admin(rs.getString(4));
				list.add(operator);
			}
			
			
		}catch (Exception e){
			e.printStackTrace();
		}finally{
			ConnectionMgr.freeResource(con, st, rs);
		}
		return list;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -