public boolean tableExists(DSLContext context) { return JooqUtils.tableExists(context, Tables.META_INFO); }
/** * "Guess" the {@link SQLDialect} from a {@link Connection} instance. * <p> * This method tries to guess the <code>SQLDialect</code> of a connection * from the its connection URL as obtained by * {@link DatabaseMetaData#getURL()}. If the dialect cannot be guessed from * the URL (e.g. when using an JDBC-ODBC bridge), further actions may be * implemented in the future. * * @see #dialect(String) */ @SuppressWarnings("deprecation") public static final SQLDialect dialect(Connection connection) { SQLDialect result = SQLDialect.SQL99; try { String url = connection.getMetaData().getURL(); result = dialect(url); } catch (SQLException ignore) {} if (result == SQLDialect.SQL99) { // If the dialect cannot be guessed from the URL, take some other // measures, e.g. by querying DatabaseMetaData.getDatabaseProductName() } return result; }
public SqlDaoIterable(Cursor<Record> result, Iterator<T> iterator, DSLContext context){ this(result, iterator, JooqUtils.getConnection(context)); }
@Override public void clear(Class component, Language lang) throws DaoException { if (!tableExists()) { return; } DSLContext context = getJooq(); try { context.delete(Tables.META_INFO) .where(Tables.META_INFO.COMPONENT.eq(component.getSimpleName())) .and(Tables.META_INFO.LANG_ID.eq(lang.getId())) .execute(); JooqUtils.commit(context); } catch (RuntimeException e) { JooqUtils.rollbackQuietly(context); throw e; } catch (DaoException e) { JooqUtils.rollbackQuietly(context); throw e; } finally { freeJooq(context); } }
public static boolean rollbackQuietly(DSLContext context) { if (context == null) { return false; } return JooqUtils.rollbackQuietly(context); }
JooqUtils.commit(context); } catch (RuntimeException e) { JooqUtils.rollbackQuietly(context); throw e; } finally {
public boolean tableExists() throws DaoException { DSLContext context = getJooq(); try { return JooqUtils.tableExists(context, Tables.META_INFO); } finally { freeJooq(context); } }
/** * Rollback the current transaction. * If a SQLException occurs while rolling back, it logs the error and returns false, * but does not rethrow the exception. * * @param context */ public static boolean rollbackQuietly(DSLContext context) { if (context == null) { return false; } return WpDataSource.rollbackQuietly(getConnection(context)); }
public WpDataSource(DataSource dataSource) throws DaoException { this.settings = new Settings(); this.dataSource = dataSource; Connection conn = null; try { conn = dataSource.getConnection(); this.dialect = JooqUtils.dialect(conn); } 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()); } finally { closeQuietly(conn); } // Postgres uses a lowercase "public" main schema if (this.dialect == SQLDialect.POSTGRES) { settings.setRenderNameStyle(RenderNameStyle.LOWER); } }
DSLContext context = getJooq(); try { if (!JooqUtils.tableExists(context, Tables.PAGEVIEW)) { return new HashMap<Language, SortedSet<DateTime>>();
public static void commit(DSLContext context) throws DaoException { try { getConnection(context).commit(); } catch (SQLException e) { throw new DaoException(e); } }
try { conn = wpDs.getConnection(); this.dialect = JooqUtils.dialect(conn); } 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());
DSLContext context = getJooq(); try { if (!JooqUtils.tableExists(context, Tables.PAGEVIEW)) { return new HashMap<Language, SortedSet<DateTime>>();
public void freeJooq(DSLContext context) { Connection conn = JooqUtils.getConnection(context); if (conn != null) { try { if (!conn.getAutoCommit()) { conn.commit(); } } catch (SQLException e) { throw new RuntimeException(e); } closeQuietly(conn); } }