[ rubbish-db ]
RubbishDatabase dbh = new RubbishDatabase(); dbh.setLogging(true); dbh.connect("jdbc:hsqldb:hsql://localhost", "sa", ""); Publisher publisher = new Publisher(); publisher.setId("07"); publisher.setName("御来利意書房"); publisher.setVolumes(new Integer(2)); publisher.setUpdate_date(new Date()); publisher.setCreate_date(new Date()); int prows = dbh.insert(publisher); println("prows=" + prows); Publisher[] publishers = (Publisher[]) dbh.select(Publisher.class, "ORDER BY ID"); for (int i = 0; i < publishers.length; i++) println(publishers[i]); Book book01 = new Book(); book01.setPublisher("07"); book01.setId("000"); book01.setTitle("獲九里伏"); book01.setAuthor("愛微意笑"); book01.setIssue_date(null); book01.setUpdate_date(new Date()); book01.setCreate_date(new Date()); Book book02 = new Book(); book02.setPublisher("07"); book02.setId("001"); book02.setTitle("蛇場"); book02.setAuthor("御素輪具"); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); book02.setIssue_date(df.parse("2001-06-01")); book02.setUpdate_date(new Date()); book02.setCreate_date(new Date()); List booklist = new ArrayList(); booklist.add(book01); booklist.add(book02); int brows = dbh.insert(booklist); println("brows=" + brows); Book[] books = (Book[]) dbh.select(Book.class, "WHERE PUBLISHER=? ORDER BY ID", "07"); for (int i = 0; i < books.length; i++) println(books[i]); 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.189, 07, 御来利意書房, 2005-09-11 11:04:44.189, 2]' prows=1 'SELECT * FROM PUBLISHER ORDER BY ID' Publisher@{create_date=1999-07-10 17:10:00.000, id=00, name=ミュンヒハウゼン出版, update_date=2005-07-10 17:10:00.000, volumes=1} Publisher@{create_date=1999-07-10 17:10:00.000, id=01, name=栄学館, update_date=2005-07-10 17:10:00.000, volumes=4} Publisher@{create_date=1999-07-10 17:10:00.000, id=02, name=時源出版, update_date=2005-07-10 17:10:00.000, volumes=4} Publisher@{create_date=1999-07-10 17:10:00.000, id=03, name=曙蓬莱新聞社, update_date=2005-07-10 17:10:00.000, volumes=4} Publisher@{create_date=1999-07-10 17:10:00.000, id=04, name=太公望書林, update_date=2005-07-10 17:10:00.000, volumes=12} Publisher@{create_date=1999-07-10 17:10:00.000, id=05, name=日本曙蓬莱武術協会, update_date=2005-07-10 17:10:00.000, volumes=5} Publisher@{create_date=1999-07-10 17:10:00.000, id=06, name=民明書房, update_date=2005-07-10 17:10:00.000, volumes=76} Publisher@{create_date=2005-09-11 11:04:44.189, id=07, name=御来利意書房, update_date=2005-09-11 11:04:44.189, volumes=2} 'INSERT INTO BOOK (AUTHOR, CREATE_DATE, ID, ISSUE_DATE, PUBLISHER, TITLE, UPDATE_DATE) VALUES (?, ?, ?, ?, ?, ?, ?) [愛微意笑, 2005-09-11 11:04:44.259, 000, null, 07, 獲九里伏, 2005-09-11 11:04:44.259]' 'INSERT INTO BOOK (AUTHOR, CREATE_DATE, ID, ISSUE_DATE, PUBLISHER, TITLE, UPDATE_DATE) VALUES (?, ?, ?, ?, ?, ?, ?) [御素輪具, 2005-09-11 11:04:44.259, 001, 2001-06-01 00:00:00.000, 07, 蛇場, 2005-09-11 11:04:44.259]' brows=2 'SELECT * FROM BOOK WHERE PUBLISHER=? ORDER BY ID [07]' Book@{author=愛微意笑, create_date=2005-09-11 11:04:44.259, id=000, issue_date=null, publisher=07, title=獲九里伏, update_date=2005-09-11 11:04:44.259} Book@{author=御素輪具, create_date=2005-09-11 11:04:44.259, id=001, issue_date=2001-06-01 00:00:00.000, publisher=07, title=蛇場, update_date=2005-09-11 11:04:44.259} rollback transaction. disconnect database.