#22 Added optional "-ignore" flag to org.hsqldb.util.ScriptTool

open
nobody
None
5
2004-05-07
2004-05-05
Mark DeSpain
No

I added an optional flag (-ignore) to the
org.hsqldb.util.ScriptTool class that, when run in batch
mode, allows the ScriptTool to proceed to execute SQL
remaining SQL statements after an SQLException is
thrown when executing one of the statements.

The change to the existing code is small. A try..catch
block was added inside the while loop of the execute()
method that caught any SQLExceptions. If the flag was
set to false (or not given), the exception is rethrown,
and the application behaves as before. If the flag is set
to true, the exception is not rethrown, a message is
printing stating that an exception was thrown, but the
while loop is now allowed to continue to execute the
remaining statements.

The motivation for adding this feature came from an
attempt to execute a SQL script that was generated by
Hibernate's SchemaExport tool (see below). The intent
of the generated script was to create new tables;
however, an SQLException was being thrown during the
attempt to drop any pre-existing tables; however, if
those tables do not exist, an SQLException is thrown
during the attemp to drop the constraint on the
Activities table.

~Mark DeSpain
markdespain@excite.com

//----------------------------------------------------
// Generated SQL
//----------------------------------------------------
alter table Activities drop constraint
FKF0ED180DFAE13213;
go
drop table Environments if exists;
go
drop table Activities if exists;
go
create table Environments (
identity INTEGER NOT NULL IDENTITY,
elevationFt DOUBLE not null,
atElevationMoreThan28Days BIT not null,
hills VARCHAR(20) not null,
temperature VARCHAR(15) not null,
humidity VARCHAR(20) not null,
terrain VARCHAR(20) not null,
wind VARCHAR(20) not null,
fan VARCHAR(20) not null,
waterTemperature VARCHAR(20) not null,
current VARCHAR(20) not null,
waves VARCHAR(20) not null
);
go
create table Activities (
identity INTEGER NOT NULL IDENTITY,
rpe DOUBLE not null,
durationHrs DOUBLE not null,
sequentialness VARCHAR(25) not null,
unusualness VARCHAR(20) not null,
activity VARCHAR(50) not null,
intensity VARCHAR(15) not null,
distanceMi DOUBLE not null,
environment INTEGER not null
);
go
alter table Activities add constraint
FKF0ED180DFAE13213 foreign key (environment)
references Environments;
go

Discussion

  • Mark DeSpain
    Mark DeSpain
    2004-05-05

    Modified source file for org.hsqldb.util.ScriptTool

     
    Attachments
  • Fred Toussi
    Fred Toussi
    2004-05-07

    • labels: 342511 -->
    • milestone: 131867 -->