RxJava based asynchronous processing utility.
リスト処理を容易に非同期化するためのユーティリティ。
- 非同期にデータを順次処理したい場合
- 大量のデータを順次処理したい場合
public class DbExportProcess extends AsyncProcess<String> {
private Connection conn = null;
// Async execure process.
@Override
public void execute() {
conn = DriverManager.getConnection("jdbc:xxxxx:xxx");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM TEST;");
while (rs.next()) {
// emit value
append(re.getString("name"));
}
}
@Overide
public void close() throws IOExcption {
if (conn != null) {
conn.close();
}
}
}
DbExportProcess proc = new DbExportProcess();
try (ClosableResult rersults : proc.run()) {
for (String name : results) {
}
} catch (IOException ioe) {
ioe.printStackTrace();
}