2012-02-13 5 views
0

내가 원하는 것은 쿼리 N 데이터베이스이며 결과를 JDBC를 통해 각 데이터베이스의 특정 파일에 저장합니다. 내가 병렬 쿼리를 생각하고 있었고 스레드 풀을 통해 생각했지만, 그 확장 가능한 무엇입니까? 더 나은 접근법 (배우 모델)이 있습니까?JDBC 쿼리 다중 데이터베이스

감사합니다.

답변

1

예, 확장 가능합니다. 항상 더 나은 접근 방법이 있지만, 가장 간단한 방법이 사용자의 필요에 맞는지 확인해야합니다. 그렇다면 더 나은 접근법을 찾지 않습니다.

대체 방법은 전혀 복잡하지 않아도됩니다.

// initialize an executor service 
ExecutorService executor = Executors.newCachedThreadPool(); 

// externalize the access to every database in a method declared in a class 
// that implements Runnable 
class Oracle implements Runnable { 
    @Override 
    public void run() { 
    // load the driver 
    // prepare the statement 
    // get the connection 
    // execute the statement and get the results 
    // save the results to a file 
    } 
} 

// execute every db access withing the executor 
executor.execute(new Oracle()); 
executor.execute(new SqlServer()); 
executor.execute(new MySql()); 
+0

저는 ExecutorService 및 ExecutorCompletionService를 사용하여 작은 개념 증명을 구현했으며 정상적으로 작동하는 것으로 보입니다. 당신의 관점에서, 다른 접근법은 무엇입니까? – Radu

+0

이 프로젝트는 http://code.google.com/p/guzz/에서 아주 흥미 롭습니다. – Radu