wrap timestamps in quotes and print more status info

This commit is contained in:
Paul Trowbridge 2022-10-24 15:17:29 +00:00
parent 54ab5645b1
commit e60a92cfdc

View File

@ -35,7 +35,7 @@ public class jrunner {
Integer cols = null; Integer cols = null;
String[] dtn = null; String[] dtn = null;
msg = "jrunner version 0.32"; msg = "jrunner version 0.34";
msg = msg + nl + "-scu source jdbc url"; msg = msg + nl + "-scu source jdbc url";
msg = msg + nl + "-scn source username"; msg = msg + nl + "-scn source username";
msg = msg + nl + "-scp source passowrd"; msg = msg + nl + "-scp source passowrd";
@ -140,6 +140,7 @@ public class jrunner {
//-------------------------------------------establish connections------------------------------------------------- //-------------------------------------------establish connections-------------------------------------------------
//source database //source database
System.out.println("------------open database connections---------------------");
try { try {
scon = DriverManager.getConnection(scu, scn, scp); scon = DriverManager.getConnection(scu, scn, scp);
} catch (SQLException e) { } catch (SQLException e) {
@ -147,16 +148,17 @@ public class jrunner {
e.printStackTrace(); e.printStackTrace();
System.exit(0); System.exit(0);
} }
System.out.println(" ✅ source database");
//destination database //destination database
try { try {
dcon = DriverManager.getConnection(dcu, dcn, dcp); dcon = DriverManager.getConnection(dcu, dcn, dcp);
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("issue connecting to desctination:"); System.out.println("issue connecting to destination:");
e.printStackTrace(); e.printStackTrace();
System.exit(0); System.exit(0);
} }
System.out.println(" ✅ destination database");
//----------------------------------------open resultset------------------------------------------------------------ //----------------------------------------open resultset------------------------------------------------------------
System.out.println("issue connecting to desctination:");
try { try {
stmt = scon.createStatement(); stmt = scon.createStatement();
rs = stmt.executeQuery(sq); rs = stmt.executeQuery(sq);
@ -183,7 +185,7 @@ public class jrunner {
try { try {
for (int i = 1; i <= cols; i++){ for (int i = 1; i <= cols; i++){
dtn[i] = rs.getMetaData().getColumnTypeName(i); dtn[i] = rs.getMetaData().getColumnTypeName(i);
System.out.println(rs.getMetaData().getColumnName(i) + ": " + dtn[i]); System.out.println(" * " + rs.getMetaData().getColumnName(i) + ": " + dtn[i]);
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
@ -230,6 +232,9 @@ public class jrunner {
case "TIME": case "TIME":
nc = "'" + rs.getString(i).replace("'","''") + "'"; nc = "'" + rs.getString(i).replace("'","''") + "'";
break; break;
case "TIMESTAMP":
nc = "'" + rs.getString(i).replace("'","''") + "'";
break;
case "BIGINT": case "BIGINT":
nc = rs.getString(i); nc = rs.getString(i);
default: default:
@ -297,6 +302,7 @@ public class jrunner {
System.out.println("issue closing connections"); System.out.println("issue closing connections");
e.printStackTrace(); e.printStackTrace();
} }
System.out.println(" rows written");
System.out.println(""); System.out.println("");
} }
} }