private void loadInstalledTables() throws SQLException { logger.info("Searching for installed tables"); Connection conn = null; try { conn = this.dataSource.getConnection(); final ResultSet rs = conn.getMetaData().getTables(conn.getCatalog(), null, null, new String[]{"TABLE"}); while (rs.next()) { this.tables.put(rs.getString("TABLE_NAME").toLowerCase(), "2.1"); } } finally { DbUtils.commitAndCloseQuietly(conn); } }
private void loadInstalledTables() throws SQLException { logger.info("Searching for installed tables"); Connection conn = null; try { conn = dataSource.getConnection(); ResultSet rs = conn.getMetaData().getTables(conn.getCatalog(), null, null, new String[]{"TABLE"}); while(rs.next()) { tables.put(rs.getString("TABLE_NAME").toLowerCase(), "2.1"); } } finally { DbUtils.commitAndCloseQuietly(conn); } }
private void loadInstalledTables() throws SQLException { logger.info("Searching for installed tables"); Connection conn = null; try { conn = this.dataSource.getConnection(); final ResultSet rs = conn.getMetaData().getTables(conn.getCatalog(), null, null, new String[]{"TABLE"}); while (rs.next()) { this.tables.put(rs.getString("TABLE_NAME").toLowerCase(), "2.1"); } } finally { DbUtils.commitAndCloseQuietly(conn); } }
@Test public void commitAndCloseQuietlyWithException() throws Exception { Connection mockConnection = mock(Connection.class); doThrow(SQLException.class).when(mockConnection).close(); DbUtils.commitAndCloseQuietly(mockConnection); verify(mockConnection).commit(); verify(mockConnection).close(); }
@Test public void testCommitAndCloseQuietlyWithNullDoesNotThrowAnSQLException() { DbUtils.commitAndCloseQuietly(null); }