private void useMVCC(Mailbox mbox) throws ServiceException, SQLException { // tell HSQLDB to use multiversion so our asserts can read while write is open PreparedStatement stmt = null; ResultSet rs = null; DbConnection conn = DbPool.getConnection(mbox); try { stmt = conn.prepareStatement("SET DATABASE TRANSACTION CONTROL MVCC"); stmt.executeUpdate(); } finally { DbPool.closeResults(rs); DbPool.quietCloseStatement(stmt); DbPool.quietClose(conn); } }
private int countInboxMessages(Mailbox mbox) throws ServiceException, SQLException { PreparedStatement stmt = null; ResultSet rs = null; DbConnection conn = DbPool.getConnection(mbox); try { stmt = conn.prepareStatement( "SELECT COUNT(*) FROM mboxgroup1.mail_item WHERE mailbox_id = ? and folder_id = ?"); stmt.setInt(1, mbox.getId()); stmt.setInt(2, Mailbox.ID_FOLDER_INBOX); rs = stmt.executeQuery(); if (rs.next()) { return rs.getInt(1); } return 0; } finally { DbPool.closeResults(rs); DbPool.quietCloseStatement(stmt); DbPool.quietClose(conn); } }