Logging information for DDL running should use the logger instead of stdout so its output can be turned off. Useful when running lots of test cases which all create clean databases.

This commit is contained in:
Mark Bell
2012-11-26 13:14:16 -05:00
parent e0d9cc3662
commit 080d398214
@@ -35,12 +35,8 @@ public class DdlGenerator {
private final DatabasePlatform dbPlatform;
private PrintStream out = System.out;
private int summaryLength = 80;
private boolean debug = true;
private boolean generateDdl;
private boolean runDdl;
@@ -218,13 +214,11 @@ public class DdlGenerator {
try {
Connection connection = t.getConnection();
out.println("runScript");
out.flush();
logger.info("Running DDL");
runStatements(expectErrors, statements, connection);
out.println("... end of script");
out.flush();
logger.info("Running DDL Complete");
t.commit();
@@ -263,19 +257,15 @@ public class DdlGenerator {
stmt = stmt.substring(0, stmt.length()-1);
}
if (debug) {
out.println("executing "+oneOf+" "+ getSummary(stmt));
out.flush();
}
logger.log(Level.FINER, "executing "+oneOf+" "+ getSummary(stmt));
pstmt = c.prepareStatement(stmt);
pstmt.execute();
} catch (Exception e) {
if (expectErrors){
out.println(" ... ignoring error executing "+getSummary(stmt)+" error: "+e.getMessage());
logger.info(" ... ignoring error executing "+getSummary(stmt)+" error: "+e.getMessage());
e.printStackTrace();
out.flush();
} else {
String msg = "Error executing stmt[" + stmt+"] error["+e.getMessage()+"]";
throw new RuntimeException(msg, e);