TransferTable(DataAccessPoint src, String name, String schema, String type, Traceable t) { Stmts = new SQLStatements(); sourceDb = src; Stmts.sSchema = ""; if (schema != null && schema.length() > 0) { Stmts.sSchema = schema; } Stmts.sType = type; Stmts.sDatabaseToConvert = src.databaseToConvert; Stmts.sSourceTable = Stmts.sDestTable = name; tracer = t; if (Stmts.sType.compareTo("TABLE") == 0) { Stmts.sSourceSelect = "SELECT * FROM " + src.helper.formatName(Stmts.sSourceTable) + ";"; } else if (Stmts.sType.compareTo("VIEW") == 0) { Stmts.sSourceSelect = ""; } }
public void visit(SQLStatements entity) { for (int i = 0; i < entity.size(); i++) wGetVisitor1().visit(entity.get(i)); }
/** * Method declaration * * @param t * @throws SQLException */ void transferAlter() throws Exception { String Statement = new String(""); if (destDb.helper.needTransferTransaction()) { try { destDb.setAutoCommit(false); } catch (Exception e) { } } if (Stmts.bTransfer == false) { tracer.trace("Table " + Stmts.sSourceTable + " not transfered"); return; } tracer.trace("Table " + Stmts.sSourceTable + ": start alter"); try { if (Stmts.bCreateIndex) { if (Stmts.sDestCreateIndex.charAt(Stmts.sDestCreateIndex.length() - 1) != ';') { Stmts.sDestCreateIndex += ";"; } int lastsemicolon = 0; int nextsemicolon = Stmts.sDestCreateIndex.indexOf(';'); while (nextsemicolon > lastsemicolon) { Statement = Stmts.sDestCreateIndex.substring(lastsemicolon, nextsemicolon); while (Statement.charAt(Statement.length() - 1) == ';') { Statement = Statement.substring(0, Statement.length() - 1); } try { tracer.trace("Executing " + Stmts.sDestCreateIndex); destDb.execute(Statement); } catch (Exception e) { tracer.trace("Ignoring error " + e.getMessage()); } lastsemicolon = nextsemicolon + 1; nextsemicolon = lastsemicolon + Stmts.sDestCreateIndex.substring(lastsemicolon).indexOf(';'); } } if (Stmts.bAlter) { if (Stmts.sDestAlter.charAt(Stmts.sDestAlter.length() - 1) != ';') { Stmts.sDestAlter += ";"; } int lastsemicolon = 0; int nextsemicolon = Stmts.sDestAlter.indexOf(';'); while (nextsemicolon > lastsemicolon) { Statement = Stmts.sDestAlter.substring(lastsemicolon, nextsemicolon); while (Statement.charAt(Statement.length() - 1) == ';') { Statement = Statement.substring(0, Statement.length() - 1); } try { tracer.trace("Executing " + Statement); destDb.execute(Statement); } catch (Exception e) { tracer.trace("Ignoring error " + e.getMessage()); } lastsemicolon = nextsemicolon + 1; nextsemicolon = lastsemicolon + Stmts.sDestAlter.substring(lastsemicolon).indexOf(';'); } } } catch (Exception e) { try { if (!destDb.getAutoCommit()) { destDb.rollback(); } } catch (Exception e1) { } throw (e); } if (!destDb.getAutoCommit()) { destDb.commit(); try { destDb.setAutoCommit(true); } catch (Exception e) { } } }