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

📄 customermanager.java

📁 这是中国移动的一个管理系统
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package com.mobile.mode;import com.mobile.util.DBUtil;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;/** * * @author st */public class CustomerManager {    private CustomerManager() {    }    private static CustomerManager manager = null;    public static CustomerManager getInstance() {        if (manager == null) {            manager = new CustomerManager();        }        return manager;    }    //是否在,,     public boolean isExist(String stype, String snumber) {        Connection conn = null;        PreparedStatement stmt = null;        ResultSet rs = null;        String sql = "select count(*) from tcustomer where id_type = ? and id_number= ? ";        try {            conn = DBUtil.getConnection();            stmt = conn.prepareStatement(sql);            stmt.setString(1, stype);            stmt.setString(2, snumber);            rs = stmt.executeQuery();            rs.next();            int is = rs.getInt(1);            if (is == 0) {                return false;            } else {                return true;            }        } catch (SQLException ex) {            ex.printStackTrace();            return false;        } finally {            DBUtil.close(rs, stmt, conn);        }    }    public Customer getByTypeNumber(String stype, String snumber) {        Connection conn = null;        PreparedStatement stmt = null;        ResultSet rs = null;        String sql = "select * from tcustomer where id_type = ? and id_number= ? ";        Customer c = null;        try {            conn = DBUtil.getConnection();            stmt = conn.prepareStatement(sql);            stmt.setString(1, stype);            stmt.setString(2, snumber);            rs = stmt.executeQuery();            if (rs.next()) {                c = new Customer();                c.setId(rs.getInt("Customer_ID"));                c.setType(rs.getString("ID_Type"));                c.setIdNumber(rs.getString("ID_Number"));                c.setName(rs.getString("Customer_Name"));                c.setBdate(rs.getDate("Customer_Birthday"));                c.setSex(rs.getString("Customer_Sex"));                c.setAddress(rs.getString("Customer_Address"));            }        } catch (SQLException ex) {            ex.printStackTrace();        } finally {            DBUtil.close(rs, stmt, conn);        }        return c;    }    public static void main(String[] args){      System.out.println(CustomerManager.getInstance().getByTypeNumber("D", "100859").getId());    }}

⌨️ 快捷键说明

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