...
This commit is contained in:
		@@ -413,6 +413,8 @@ public class DataImport
 | 
			
		||||
                                                      String password,
 | 
			
		||||
                                                      ArrayList<TelsalePolicyRecord> policyList )
 | 
			
		||||
    {
 | 
			
		||||
        Connection conn = null;
 | 
			
		||||
        CallableStatement statement = null;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package com.cpic.util.staff;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Kane on 2017/3/28.
 | 
			
		||||
 * 准备废弃
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import java.io.*;
 | 
			
		||||
@@ -19,25 +20,26 @@ public class StaffInfo
 | 
			
		||||
 | 
			
		||||
    private static String oracleURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
 | 
			
		||||
 | 
			
		||||
    public StaffInfo(String staffCode) throws
 | 
			
		||||
            StaffCodeNotExistException,
 | 
			
		||||
            OracleConnectionException,
 | 
			
		||||
            ClassNotFoundException,
 | 
			
		||||
            SQLException
 | 
			
		||||
    public StaffInfo( String staffCode )
 | 
			
		||||
            throws StaffCodeNotExistException,
 | 
			
		||||
                   OracleConnectionException,
 | 
			
		||||
                   ClassNotFoundException,
 | 
			
		||||
                   SQLException
 | 
			
		||||
    {
 | 
			
		||||
        if (staffCode.length() < 3) {
 | 
			
		||||
            throw new StaffCodeNotExistException(staffCode + "不存在。");
 | 
			
		||||
        if ( staffCode.length() < 3 )
 | 
			
		||||
        {
 | 
			
		||||
            throw new StaffCodeNotExistException( staffCode + "不存在。" );
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //url要改成可配置的
 | 
			
		||||
        //String oracleURL = "jdbc:oracle:thin:@10.187.11.164:1521:xmcx1";
 | 
			
		||||
        //String oracleURL      = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
 | 
			
		||||
        String oracleURL      = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
 | 
			
		||||
        String oracleUserName = "idst0";
 | 
			
		||||
        String oraclePassword = "cpic123456";
 | 
			
		||||
 | 
			
		||||
        this.staffCode = staffCode;
 | 
			
		||||
 | 
			
		||||
        Class.forName("oracle.jdbc.driver.OracleDriver");
 | 
			
		||||
        Class.forName( "oracle.jdbc.driver.OracleDriver" );
 | 
			
		||||
 | 
			
		||||
        Connection        conn   = null;
 | 
			
		||||
        PreparedStatement stmt   = null;
 | 
			
		||||
@@ -56,32 +58,43 @@ public class StaffInfo
 | 
			
		||||
                        "   AND ry.department_code = bm.department_code\n" +
 | 
			
		||||
                        "   AND ry.section_office_code = ksh.section_office_code";
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            conn = DriverManager.getConnection(oracleURL, oracleUserName, oraclePassword);
 | 
			
		||||
            stmt = conn.prepareStatement(sql);
 | 
			
		||||
            stmt.setString(1, staffCode);
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            conn = DriverManager.getConnection( oracleURL, oracleUserName, oraclePassword );
 | 
			
		||||
            stmt = conn.prepareStatement( sql );
 | 
			
		||||
            stmt.setString( 1, staffCode );
 | 
			
		||||
            result = stmt.executeQuery();
 | 
			
		||||
 | 
			
		||||
            if (result.next()) {
 | 
			
		||||
                staffName         = result.getString("staff_name");
 | 
			
		||||
                sectionOfficeCode = result.getString("section_office_code");
 | 
			
		||||
                sectionOfficeName = result.getString("section_office_name");
 | 
			
		||||
                departmentCode    = result.getString("department_code");
 | 
			
		||||
                departmentName    = result.getString("department_name");
 | 
			
		||||
            if ( result.next() )
 | 
			
		||||
            {
 | 
			
		||||
                staffName         = result.getString( "staff_name" );
 | 
			
		||||
                sectionOfficeCode = result.getString( "section_office_code" );
 | 
			
		||||
                sectionOfficeName = result.getString( "section_office_name" );
 | 
			
		||||
                departmentCode    = result.getString( "department_code" );
 | 
			
		||||
                departmentName    = result.getString( "department_name" );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (staffName.isEmpty() == true) {
 | 
			
		||||
            if ( staffName.isEmpty() == true )
 | 
			
		||||
            {
 | 
			
		||||
                //没查到数据
 | 
			
		||||
                throw new StaffCodeNotExistException("工号" + staffCode + "不存在。");
 | 
			
		||||
                throw new StaffCodeNotExistException( "工号" + staffCode + "不存在。" );
 | 
			
		||||
            }
 | 
			
		||||
        } catch (SQLException error) {
 | 
			
		||||
            throw new OracleConnectionException(error.getMessage());
 | 
			
		||||
        } finally {
 | 
			
		||||
            try {
 | 
			
		||||
                if (conn != null) {
 | 
			
		||||
        }
 | 
			
		||||
        catch ( SQLException error )
 | 
			
		||||
        {
 | 
			
		||||
            throw new OracleConnectionException( error.getMessage() );
 | 
			
		||||
        }
 | 
			
		||||
        finally
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                if ( conn != null )
 | 
			
		||||
                {
 | 
			
		||||
                    conn.close();
 | 
			
		||||
                }
 | 
			
		||||
            } catch (SQLException error) {
 | 
			
		||||
            }
 | 
			
		||||
            catch ( SQLException error )
 | 
			
		||||
            {
 | 
			
		||||
                //不处理了
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user