[ rubbish-db ]

ソース

RubbishDatabase dbh = new RubbishDatabase(new HsqldbExceptionFactory());
dbh.setLogging(true);

dbh.connect("jdbc:hsqldb:hsql://localhost", "sa", "");

Publisher publisher = new Publisher();
publisher.setId("07");
publisher.setName("御来利意書房");
publisher.setVolumes(new Integer(-1));
publisher.setUpdate_date(new Date());
publisher.setCreate_date(new Date());

try {
    dbh.insert(publisher);
} catch (SQLCheckException e) {
    System.out.println(e);
}

dbh.rollback();
dbh.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
'INSERT INTO PUBLISHER (CREATE_DATE, ID, NAME, UPDATE_DATE, VOLUMES) VALUES (?, ?, ?, ?, ?) [2005-09-11 11:04:44.680, 07, 御来利意書房, 2005-09-11 11:04:44.680, -1]'
rubbish.db.exception.SQLCheckException: java.sql.SQLException: Check constraint violation CK_VOLUMES table: PUBLISHER in statement [INSERT INTO PUBLISHER (CREATE_DATE, ID, NAME, UPDATE_DATE, VOLUMES) VALUES (?, ?, ?, ?, ?)] (error code=-157, SQLState=23000, SQL='INSERT INTO PUBLISHER (CREATE_DATE, ID, NAME, UPDATE_DATE, VOLUMES) VALUES (?, ?, ?, ?, ?) [2005-09-11 11:04:44.680, 07, 御来利意書房, 2005-09-11 11:04:44.680, -1]')
rollback transaction.
disconnect database.