public void commitTrans() throws DriverException, FreeingResourcesException {
if (driver instanceof DBTransactionalDriver) {
try {
((DBTransactionalDriver) driver).beginTrans(ds.getConnection());
} catch (SQLException e) {
throw new DriverException(e);
}
}
StringBuffer totalSQL = new StringBuffer();
try {
mes.commit(ds.getConnection());
String sql = "";
for (int i = 0; i < dbws.getInstructionCount(); i++) {
sql = dbws.getInstruction(i);
logger.log(Level.INFO, "instruction " + i + ": " + sql);
if (sql != null) {
totalSQL.append(sql).append(";");
}
}
ds.execute(totalSQL.toString());
} catch (SQLException e) {
if (driver instanceof DBTransactionalDriver) {
try {
((DBTransactionalDriver) driver)
.rollBackTrans(ds.getConnection());
} catch (SQLException e1) {
throw new DriverException(e1);
}
}
throw new DriverException(e.getMessage() + ":" + totalSQL, e);
}
if (driver instanceof DBTransactionalDriver) {
try {
((DBTransactionalDriver) driver).commitTrans(ds.getConnection());
} catch (SQLException e) {
throw new DriverException(e);
}
}
try {
dbws = null;