2012-12-14 2 views
0

MySQL 데이터베이스에서 데이터를 추출하고 제거하는 메소드가 있습니다.자바가 이전까지 완료 될 때까지 기다리십시오. 시도가 완료되었습니다.

프로세스의 다음 단계는이 데이터를 Oracle 데이터베이스로 이동하는 것입니다.

그러나 MySQL에서 데이터를 추출하고 정리하는 과정에서 oracle db에 대한 연결이 있습니다. 이것은 nescessary가 아니며 추출 과정을 상당히 지연시킵니다.

extracion/cleaning 프로세스가 완료되고 Java가 Oracle에 연결될 때까지 Java가 대기하도록하려면 어떻게해야합니까? 설명을 위해

public void ConvertFiles() { 

    try { 

     connectToDB(); 

     RawFile tempFile = new RawFile(super.mFileType); 
     try { 
      ArrayList<String> values = new ArrayList<String>(); 

      try { 
       Statement stmt = conn.createStatement(); 
       ResultSet result = stmt.executeQuery("SELECT * FROM coffeedata"); 
       int ii = 0; 
       while (result.next()) { 
        ii++; 
        System.out.print("Reading Row:" + ii + "/" + 41429 + "\n"); 
        mStore = (result.getString(1)); 
        mCategory = (result.getString(2)); 
        mName = (result.getString(3)); 

        // Add columns 2007 Q1 - Q4 t/m 2009 Q1 - Q2 to ArrayList 


        for (int i = 4; i < 14; i++) { 
         values.add("" + result.getInt(i)); 

        } 
        tempFile.addData(new SQLData(mCategory, mName, values, mStore)); 

        try { 
         OracleController.DataToOracle(); 

        } catch (Exception e) { 
         System.out.println(e.getMessage()); 

        } 
       } 

       tempFile.CleanCategory(); 
       mRawFiles.add(tempFile); 

      } catch (Exception e) { 
       System.out.println(e.getMessage()); 
       closeDBConnection(); 

      } 
     } catch (Exception e) { 
      System.out.println(e.getMessage()); 
      //return values; 
      //System.out.println(values); 


     } 
    } catch (Exception e) { 
     System.out.println(e.getMessage()); 
    } 

:

내 코드입니다

try { 
    OracleController.DataToOracle(); 

} 
+0

코드를 게시하십시오. –

+0

데이터베이스에서 데이터를 "추출하고 지우려면"연결이 필요합니다. – Bohemian

+0

예, 문제는 nescessary가 아닐 때 Oracle 데이터베이스에 대한 연결을 유지 관리하는 것입니다. 외과/청소 과정이 완료된 후 그 연결 만 필요합니다. – Forza

답변

1

코드를 리팩토링과 try - catch - finallytry 블록을 배치 :이 이전이 완료 될 때까지 기다려보십시오 수 있도록하려면 기다리고 싶어.

try{ 
    //block that you need to excecute before 
} catch { ... } 
// Than your block 
try { 
    OracleController.DataToOracle(); 
} catch (Exception e) 


        } 
+0

시도에 도달하지 못했습니다. 사용 가능한 실행 가능 위치가 없음 – Forza

+0

Nvm, 해결 : thx man! – Forza

관련 문제