在开发机上建库,建表。
This commit is contained in:
		@@ -9,6 +9,7 @@
 | 
			
		||||
        <webroots>
 | 
			
		||||
          <root url="file://$MODULE_DIR$/web" relative="/" />
 | 
			
		||||
        </webroots>
 | 
			
		||||
        <sourceRoots />
 | 
			
		||||
      </configuration>
 | 
			
		||||
    </facet>
 | 
			
		||||
  </component>
 | 
			
		||||
 
 | 
			
		||||
@@ -17,74 +17,71 @@ public class StaffInfo
 | 
			
		||||
    private String departmentCode;
 | 
			
		||||
    private String departmentName;
 | 
			
		||||
 | 
			
		||||
    public StaffInfo( String staffCode ) throws StaffCodeNotExistException, OracleConnectionException, ClassNotFoundException, SQLException {
 | 
			
		||||
        if ( staffCode.length() < 3 )
 | 
			
		||||
        {
 | 
			
		||||
            throw new StaffCodeNotExistException( staffCode + "不存在。");
 | 
			
		||||
    private static String oracleURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
 | 
			
		||||
 | 
			
		||||
    public StaffInfo(String staffCode) throws
 | 
			
		||||
            StaffCodeNotExistException,
 | 
			
		||||
            OracleConnectionException,
 | 
			
		||||
            ClassNotFoundException,
 | 
			
		||||
            SQLException
 | 
			
		||||
    {
 | 
			
		||||
        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;
 | 
			
		||||
        ResultSet result = null;
 | 
			
		||||
        Connection        conn   = null;
 | 
			
		||||
        PreparedStatement stmt   = null;
 | 
			
		||||
        ResultSet         result = null;
 | 
			
		||||
 | 
			
		||||
        String sql =
 | 
			
		||||
                "SELECT ry.staff_name,\n" +
 | 
			
		||||
                "       ksh.section_office_code,\n" +
 | 
			
		||||
                "       ksh.section_office_name,\n" +
 | 
			
		||||
                "       bm.department_code,\n" +
 | 
			
		||||
                "       bm.department_name\n" +
 | 
			
		||||
                "  FROM idst0.rydm_t ry,\n" +
 | 
			
		||||
                "       idst0.ks_t   ksh,\n" +
 | 
			
		||||
                "       idst0.bm_t   bm\n" +
 | 
			
		||||
                " WHERE ry.staff_code = ?\n" +
 | 
			
		||||
                "   AND ry.department_code = bm.department_code\n" +
 | 
			
		||||
                "   AND ry.section_office_code = ksh.section_office_code";
 | 
			
		||||
                        "       ksh.section_office_code,\n" +
 | 
			
		||||
                        "       ksh.section_office_name,\n" +
 | 
			
		||||
                        "       bm.department_code,\n" +
 | 
			
		||||
                        "       bm.department_name\n" +
 | 
			
		||||
                        "  FROM idst0.rydm_t ry,\n" +
 | 
			
		||||
                        "       idst0.ks_t   ksh,\n" +
 | 
			
		||||
                        "       idst0.bm_t   bm\n" +
 | 
			
		||||
                        " WHERE ry.staff_code = ?\n" +
 | 
			
		||||
                        "   AND ry.department_code = bm.department_code\n" +
 | 
			
		||||
                        "   AND ry.section_office_code = ksh.section_office_code";
 | 
			
		||||
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            conn = DriverManager.getConnection( oracleURL, oracleUserName, oraclePassword );
 | 
			
		||||
        try {
 | 
			
		||||
            conn = DriverManager.getConnection(oracleURL, oracleUserName, oraclePassword);
 | 
			
		||||
            stmt = conn.prepareStatement(sql);
 | 
			
		||||
            stmt.setString( 1, staffCode );
 | 
			
		||||
            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 + "不存在。");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        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