Our company has written a rather complicated program for transferring data from one database to another. The data that you intend to transfer is marked with a “1” (String / Varchar2) in a specific column. I cannot explain why this is not just a numeric or Boolean field. I think this is a historical remnant.
ResultSet is created as follows:
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
ResultSet extractedData = stmt.executeQuery(sql);
If something is found, extract it to a file:
if (extractedData.next()) {
writeDataToFile(extractedData)
}
A simplified recording method is as follows:
private void writeDataToFile(ResultSet extractedData) {
extractedData.beforeFirst();
writeLines(extractedData);
}
In writeLines()we repeat all the text ResultSetand write it to a file.
Upon completion of this, we can mark the data as migrated by setting the value in the column to "0". We cannot do this earlier if an exception occurs.
extractedData.beforeFirst();
while (extractedData.next()) {
extractedData.updateString(updateColumn, "0");
extractedData.updateRow();
}
, updateRow() SQLException " "
. , 2 .
- , ?