[ rubbish-db ]
public void sample_dao_count() throws Exception { RubbishDatabase dbh = new RubbishDatabase(); dbh.setLogging(true); dbh.connect("jdbc:hsqldb:hsql://localhost", "sa", ""); DAOFactory factory = new DAOFactory(dbh, "C:/eclipse/workspace/rubbish-db/sample/src/sample/hsqldb/dao"); BookDAO bookDAO = (BookDAO) factory._new(BookDAO.class); println("----------"); int rows01 = bookDAO.countByPK("06", "002"); println("rows=" + rows01); println("----------"); Integer rows02 = bookDAO.countByPublisher("04"); println("rows=" + rows02); println("----------"); int rows03 = bookDAO.countById("001"); println("rows=" + rows03); println("----------"); int rows04 = bookDAO.countByPublisherAuthorIssue_date("05", "竹乃元秀路", null); println("rows=" + rows04); println("----------"); dbh.disconnect(); }
connect database 'url=jdbc:hsqldb:hsql://localhost, user=sa, password='. ---------- 'SELECT COUNT(*) FROM BOOK WHERE PUBLISHER = ? AND ID = ? [06, 002]' rows=1 ---------- 'SELECT COUNT(*) FROM BOOK WHERE PUBLISHER = ? [04]' rows=12 ---------- 'SELECT COUNT(*) FROM BOOK WHERE ID = ? [001]' rows=6 ---------- 'SELECT COUNT(*) FROM BOOK WHERE PUBLISHER = ? AND AUTHOR = ? AND ISSUE_DATE IS NULL [05, 竹乃元秀路]' rows=1 ---------- disconnect database.