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

📄 mobilemanager.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;import java.util.logging.Level;import java.util.logging.Logger;/** * * @author st */public class MobileManager {    private MobileManager() {    }    private static MobileManager manager = null;    public static MobileManager getInstance() {        if (manager == null) {            manager = new MobileManager();        }        return manager;    }    // 1300000001 - 13000000099    public boolean save(String sstart, String send, String mType)  {        Connection conn = null;        PreparedStatement stmt = null;        int rs = -1;        String sql = "insert into TMobiles values(?,?,null,'N')";        try {            conn = DBUtil.getConnection();            stmt = conn.prepareStatement(sql);            long start = Long.parseLong(sstart);            long end = Long.parseLong(send);            conn.setAutoCommit(false);            for (long i = start; i <= end; i++) {                stmt.setString(1, "" + i);                stmt.setString(2, mType);                rs = stmt.executeUpdate();            }            conn.commit();            conn.setAutoCommit(true);        } catch (SQLException ex) {            ex.printStackTrace();        } finally {            DBUtil.close(null, stmt, conn);        }        if (rs == 0) {            return false;        } else {            return true;        }    }    public boolean checkNumber(String start, String end,String mtype) {        String sql = "select count(*) from tmobiles where mobile_number between ? and ? and mobile_type = ? ";        Connection conn = null;        PreparedStatement stmt = null;        ResultSet rs = null;        int is = -1;        try {            conn = DBUtil.getConnection();            stmt = conn.prepareStatement(sql);            stmt.setString(1, start);            stmt.setString(2, end);            stmt.setString(3, mtype);            rs = stmt.executeQuery();                        rs.next();            is =  rs.getInt(1);            if(is == 0){             return true;            }else{             return false;            }                    } catch (SQLException ex) {            Logger.getLogger(MobileManager.class.getName()).log(Level.SEVERE, null, ex);           return false;        }finally{           DBUtil.close(rs, stmt, conn);        }    }    public static void main(String[] args) {        System.out.println(MobileManager.getInstance().checkNumber("15000000001","15000000002","SIM"));    }}

⌨️ 快捷键说明

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