@Override public void close() throws Exception { connectionSource.close(); } }
@Override public void close() throws IOException { connectionSource.close(); } }
@Override public void close() throws IOException { cs.close(); if (!isOkay()) { throw new IOException("Wrapped connection was not okay on close"); } for (WrappedConnection wrapped : wrappedConnections.values()) { wrapped.close(); } wrappedConnections.clear(); }
public void createTables(List<String> tableClassNames, DataSourceInstallationReport schemaReport) throws ApsSystemException { ConnectionSource connectionSource = null; try { connectionSource = this.createConnectionSource(); this.createTables(tableClassNames, connectionSource, schemaReport); } catch (Throwable t) { _logger.error("Error creating tables to db {}", this.getDatabaseName(), t); throw new ApsSystemException("Error creating tables to db " + this.getDatabaseName(), t); } finally { if (connectionSource != null) { try { connectionSource.close(); } catch (SQLException ex) {} } } }
public void dropTables(List<String> tableClassNames) throws ApsSystemException { ConnectionSource connectionSource = null; try { connectionSource = this.createConnectionSource(); this.dropTables(tableClassNames, connectionSource); } catch (Throwable t) { _logger.error("Error dropping tables to db {}", this.getDatabaseName(), t); throw new ApsSystemException("Error dropping tables to db " + this.getDatabaseName(), t); } finally { if (connectionSource != null) { try { connectionSource.close(); } catch (SQLException ex) {} } } }
try { if (source != null) { source.close();
public void createTables(List<String> tableClassNames, DataSourceInstallationReport schemaReport) throws ApsSystemException { ConnectionSource connectionSource = null; try { connectionSource = this.createConnectionSource(); this.createTables(tableClassNames, connectionSource, schemaReport); } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "createTables", "Error creating tables into db " + this.getDatabaseName()); throw new ApsSystemException("Error creating tables to db " + this.getDatabaseName(), t); } finally { if (connectionSource != null) { try { connectionSource.close(); } catch (SQLException ex) {} } } }
private void doMain(String[] args) throws Exception { ConnectionSource connectionSource = null; try { // create our data-source for the database connectionSource = new JdbcConnectionSource(DATABASE_URL); // setup our database and DAOs setupDatabase(connectionSource); // read and write some data readWriteData(); // do a bunch of bulk operations readWriteBunch(); // show how to use the SelectArg object useSelectArgFeature(); // show how to use the SelectArg object useTransactions(connectionSource); System.out.println("\n\nIt seems to have worked\n\n"); } finally { // destroy the data source which should close underlying connections if (connectionSource != null) { connectionSource.close(); } } }
@Test public void testCreateDbTypeDataSource() throws Exception { ConnectionSource dataSource = null; try { String dbUrl = "jdbc:h2:mem:ormlitetest"; dataSource = new JdbcConnectionSource(dbUrl, new H2DatabaseType()); dataSource.close(); } finally { if (dataSource != null) { dataSource.getReadOnlyConnection(null).close(); } } } }