[ rubbish-db ]

ソース

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

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

Class[] types01 = { Publisher.class, Book.class };
Map jtabs01 = dbh.selectRow(types01,
        "PUBLISHER.ID=? AND BOOK.ID=? ORDER BY BOOK.ID", "04", "000");

Publisher publisher01 = (Publisher) jtabs01.get(Publisher.class);
Book book01 = (Book) jtabs01.get(Book.class);
println(publisher01.getName() + ", " + publisher01.getUpdate_date() + " / " + book01.getTitle() + ", "
        + book01.getUpdate_date());

Map types02 = new HashMap();
types02.put("PU", Publisher.class);
types02.put("BO", Book.class);
Map jtabs02 = dbh.selectRow(types02, "PU.ID=BO.PUBLISHER AND PU.ID=? AND BO.ID=? ORDER BY BO.ID", "04",
        "001");

Publisher publisher02 = (Publisher) jtabs02.get(Publisher.class);
Book book02 = (Book) jtabs02.get(Book.class);
println(publisher02.getName() + ", " + publisher02.getUpdate_date() + " / " + book02.getTitle() + ", "
        + book02.getUpdate_date());

dbh.disconnect();

結果

connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='.
'SELECT PUBLISHER.CREATE_DATE, PUBLISHER.ID, PUBLISHER.NAME, PUBLISHER.UPDATE_DATE, PUBLISHER.VOLUMES, BOOK.AUTHOR, BOOK.CREATE_DATE, BOOK.ID, BOOK.ISSUE_DATE, BOOK.PUBLISHER, BOOK.TITLE, BOOK.UPDATE_DATE FROM PUBLISHER, BOOK WHERE PUBLISHER.ID=BOOK.PUBLISHER AND PUBLISHER.ID=? AND BOOK.ID=? ORDER BY BOOK.ID [04, 000]'
太公望書林, 2005-07-10 17:10:00.000 / あなたにも出来る!中国拳法修行百科, 2005-06-10 17:10:00.000
'SELECT BO.AUTHOR, BO.CREATE_DATE, BO.ID, BO.ISSUE_DATE, BO.PUBLISHER, BO.TITLE, BO.UPDATE_DATE, PU.CREATE_DATE, PU.ID, PU.NAME, PU.UPDATE_DATE, PU.VOLUMES FROM BOOK BO, PUBLISHER PU WHERE PU.ID=BO.PUBLISHER AND PU.ID=? AND BO.ID=? ORDER BY BO.ID [04, 001]'
太公望書林, 2005-07-10 17:10:00.000 / エーゲ海-古代格闘史の浪漫-, 2005-06-10 17:10:00.000
disconnect database.