/** * In general, open connections are reclaimed and harmless */ public void close() throws IOException { if (dialect == SQLDialect.H2) { Statement stm = null; Connection cnx = null; try { cnx = getConnection(); stm = cnx.createStatement(); stm.execute("SHUTDOWN;"); stm.close(); } catch (SQLException e) { throw new IOException(e); } finally { closeQuietly(cnx); } } }
public DSLContext getJooq() throws DaoException { try { return DSL.using(getConnection(), dialect, settings); } catch (SQLException e) { throw new DaoException("SQL Dao Failed. Check if the table exists / if the desired information has been parsed and stored in the database\n" + e.toString()); } }
/** * Optimizes the performance of the database for some table. * On postgres this translates to vacuum analyze. * On h2 it does nothing. */ public void optimize(String table) throws DaoException { if (dialect == SQLDialect.POSTGRES) { Connection conn=null; try { conn = getConnection(); conn.setAutoCommit(true); Statement st = conn.createStatement(); st.execute("VACUUM ANALYZE " + table); st.close(); } catch (SQLException e) { throw new DaoException(e); } finally { if (conn != null) { try { conn.setAutoCommit(true); } catch (Exception e) {} closeQuietly(conn); } } } }
/** * Optimizes the performance of the database. * On postgres this translates to vacuum analyze. * On h2 it does nothing. */ public void optimize() throws DaoException { if (dialect == SQLDialect.POSTGRES) { Connection conn=null; try { conn = getConnection(); conn.setAutoCommit(true); Statement st = conn.createStatement(); st.execute("VACUUM ANALYZE VERBOSE;"); st.close(); } catch (SQLException e) { throw new DaoException(e); } finally { if (conn != null) { try { conn.setAutoCommit(true); } catch (Exception e) {} closeQuietly(conn); } } } }
Connection conn=null; try { conn = getConnection(); for (String s : script.split(";")) { if (s.replaceAll(";", "").trim().isEmpty()) {
@Override public boolean runDiagnostic(PrintWriter writer) { Config config = null; try { config = env.getConfigurator().getConfig(WpDataSource.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e); } boolean passed = true; try { WpDataSource ds = env.getConfigurator().get(WpDataSource.class); ds.getConnection().close(); writer.write("Connection to database succeeded. Active configuration:\n"); } catch (Exception e) { writer.write("Connection to database FAILED! Active configuration:\n"); passed = false; } for (Map.Entry<String, ConfigValue > entry : config.entrySet()) { writer.write("\t" + entry.getKey() + ": " + entry.getValue().render() + "\n"); } return passed; } }
private void insertBatches() throws DaoException, SQLException, InterruptedException { boolean finished = false; Connection cnx = ds.getConnection(); if (isPostGisLoader){ try {
@Override public boolean runDiagnostic(PrintWriter writer) { Config config = null; try { config = env.getConfigurator().getConfig(WpDataSource.class, null); } catch (ConfigurationException e) { throw new IllegalStateException(e); } boolean passed = true; try { WpDataSource ds = env.getConfigurator().get(WpDataSource.class); ds.getConnection().close(); writer.write("Connection to database succeeded. Active configuration:\n"); } catch (Exception e) { writer.write("Connection to database FAILED! Active configuration:\n"); passed = false; } for (Map.Entry<String, ConfigValue > entry : config.entrySet()) { writer.write("\t" + entry.getKey() + ": " + entry.getValue().render() + "\n"); } return passed; } }
Connection conn = null; try { conn = wpDs.getConnection(); this.dialect = JooqUtils.dialect(conn); } catch (SQLException e) {