print sql statements on failure
This commit is contained in:
		
							parent
							
								
									1cb878bdb2
								
							
						
					
					
						commit
						ac59b46e1f
					
				@ -35,8 +35,7 @@ public class jrunner {
 | 
				
			|||||||
        Integer cols = null;
 | 
					        Integer cols = null;
 | 
				
			||||||
        String[] dtn = null;
 | 
					        String[] dtn = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        msg = "Help:";
 | 
					        msg = "jrunner version 0.29";
 | 
				
			||||||
        msg = msg + nl + "jrunner version 0.28";
 | 
					 | 
				
			||||||
        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";
 | 
				
			||||||
@ -186,6 +185,7 @@ public class jrunner {
 | 
				
			|||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            System.exit(0);
 | 
					            System.exit(0);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        //-------------------------------build & execute sql-------------------------------------------------------------
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            while (rs.next()) {
 | 
					            while (rs.next()) {
 | 
				
			||||||
                r++;
 | 
					                r++;
 | 
				
			||||||
@ -193,10 +193,8 @@ public class jrunner {
 | 
				
			|||||||
                nr = "";
 | 
					                nr = "";
 | 
				
			||||||
                for (int i = 1; i <= cols; i++){
 | 
					                for (int i = 1; i <= cols; i++){
 | 
				
			||||||
                    nc = rs.getString(i);
 | 
					                    nc = rs.getString(i);
 | 
				
			||||||
                    Boolean dnull = false;
 | 
					 | 
				
			||||||
                    if (rs.wasNull()) {
 | 
					                    if (rs.wasNull()) {
 | 
				
			||||||
                        nc = "NULL";
 | 
					                        nc = "NULL";
 | 
				
			||||||
                        dnull = true;
 | 
					 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        switch (dtn[i]){
 | 
					                        switch (dtn[i]){
 | 
				
			||||||
                            case "VARCHAR":
 | 
					                            case "VARCHAR":
 | 
				
			||||||
@ -240,10 +238,11 @@ public class jrunner {
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    nr = nr + nc;
 | 
					                    nr = nr + nc;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                //System.out.println(nr);
 | 
					                //add a comma to the end of the VALUES block to accomodate a new row
 | 
				
			||||||
                if (sql!="") {
 | 
					                if (sql!="") {
 | 
				
			||||||
                    sql = sql + ",";
 | 
					                    sql = sql + ",";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                //add the new row to the VALUES block
 | 
				
			||||||
                sql = sql + "(" + nr + ")";
 | 
					                sql = sql + "(" + nr + ")";
 | 
				
			||||||
                if (r == 250){
 | 
					                if (r == 250){
 | 
				
			||||||
                    r = 0;
 | 
					                    r = 0;
 | 
				
			||||||
@ -255,21 +254,25 @@ public class jrunner {
 | 
				
			|||||||
                        System.out.println(t);
 | 
					                        System.out.println(t);
 | 
				
			||||||
                    } catch (SQLException e) {
 | 
					                    } catch (SQLException e) {
 | 
				
			||||||
                        e.printStackTrace();
 | 
					                        e.printStackTrace();
 | 
				
			||||||
 | 
					                        System.out.println(sql);
 | 
				
			||||||
                        System.exit(0);
 | 
					                        System.exit(0);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    sql = "";
 | 
					                    sql = "";
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            //if the sql is not empty, execute
 | 
				
			||||||
 | 
					            if (sql != "") {
 | 
				
			||||||
                sql = "INSERT INTO " + dt + " VALUES " + "\n" + sql;
 | 
					                sql = "INSERT INTO " + dt + " VALUES " + "\n" + sql;
 | 
				
			||||||
            //System.out.println(sql);
 | 
					 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    stmtd = dcon.createStatement();
 | 
					                    stmtd = dcon.createStatement();
 | 
				
			||||||
                    stmtd.executeUpdate(sql);
 | 
					                    stmtd.executeUpdate(sql);
 | 
				
			||||||
                    System.out.println(t);
 | 
					                    System.out.println(t);
 | 
				
			||||||
                } catch (SQLException e) {
 | 
					                } catch (SQLException e) {
 | 
				
			||||||
                    e.printStackTrace();
 | 
					                    e.printStackTrace();
 | 
				
			||||||
 | 
					                    System.out.println(sql);
 | 
				
			||||||
                    System.exit(0);
 | 
					                    System.exit(0);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } catch (SQLException e) {
 | 
					        } catch (SQLException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            System.exit(0);
 | 
					            System.exit(0);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user