@Override public Connection getConnection() { return session.getConnection(); }
connection = sqlSession.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet tables = null;
@Override public boolean isRecursiveQuerySupported(SqlSession session) { // Retrieve database version string from JDBC connection String versionString; try { Connection connection = session.getConnection(); DatabaseMetaData metaData = connection.getMetaData(); versionString = metaData.getDatabaseProductVersion(); } catch (SQLException e) { throw new PersistenceException("Cannot determine whether " + "MySQL / MariaDB supports recursive queries.", e); } try { // Parse MySQL / MariaDB version from version string MySQLVersion version = new MySQLVersion(versionString); logger.debug("Database recognized as {}.", version); // Recursive queries are supported for MariaDB 10.2.2+ and // MySQL 8.0.1+ return version.isAtLeast(MARIADB_SUPPORTS_CTE) || version.isAtLeast(MYSQL_SUPPORTS_CTE); } catch (IllegalArgumentException e) { logger.debug("Unrecognized MySQL / MariaDB version string: " + "\"{}\". Assuming database engine does not support " + "recursive queries.", session); return false; } }
public Session openSession(CommandContext commandContext) { DbSqlSession dbSqlSession = new DbSqlSession(this, commandContext.getEntityCache()); if (getDatabaseSchema() != null && getDatabaseSchema().length() > 0) { try { dbSqlSession.getSqlSession().getConnection().setSchema(getDatabaseSchema()); } catch (SQLException e) { throw new ActivitiException("Could not set database schema on connection", e); } } if (getDatabaseCatalog() != null && getDatabaseCatalog().length() > 0) { try { dbSqlSession.getSqlSession().getConnection().setCatalog(getDatabaseCatalog()); } catch (SQLException e) { throw new ActivitiException("Could not set database catalog on connection", e); } } return dbSqlSession; }
String exceptionSqlStatement = null; try { Connection connection = sqlSession.getConnection(); Exception exception = null; byte[] bytes = IoUtil.readInputStream(inputStream,
try { result.setTableName(tableName); DatabaseMetaData metaData = getDbSqlSession().getSqlSession().getConnection().getMetaData();
Connection connection = null; try { connection = getDbSqlSession().getSqlSession().getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet tables = null;
public Connection getConnection() { return wrappedSession.getConnection(); }
}); verifyDelegation(DbSessionImpl::getConnection, s -> verify(s).getConnection());
@Override public Connection getConnection() { final SqlSession sqlSession = localSqlSession.get(); if (sqlSession == null) { throw new SqlSessionException("Error: Cannot get connection. No managed session is started."); } return sqlSession.getConnection(); }
@Override public Connection getConnection() { final SqlSession sqlSession = localSqlSession.get(); if (sqlSession == null) { throw new SqlSessionException("Error: Cannot get connection. No managed session is started."); } return sqlSession.getConnection(); }
public boolean isTablePresent(String tableName) { tableName = prependDatabaseTablePrefix(tableName); Connection connection = null; try { connection = sqlSession.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet tables = null; String schema = this.connectionMetadataDefaultSchema; if (dbSqlSessionFactory.getDatabaseSchema()!=null) { schema = dbSqlSessionFactory.getDatabaseSchema(); } String databaseType = dbSqlSessionFactory.getDatabaseType(); if (DbSqlSessionFactory.POSTGRES.equals(databaseType)) { tableName = tableName.toLowerCase(); } try { tables = databaseMetaData.getTables(this.connectionMetadataDefaultCatalog, schema, tableName, JDBC_METADATA_TABLE_TYPES); return tables.next(); } finally { if (tables != null) { tables.close(); } } } catch (Exception e) { throw LOG.checkDatabaseTableException(e); } }
public boolean isTablePresent(String tableName) { tableName = prependDatabaseTablePrefix(tableName); Connection connection = null; try { connection = sqlSession.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); ResultSet tables = null; String schema = this.connectionMetadataDefaultSchema; if (dbSqlSessionFactory.getDatabaseSchema()!=null) { schema = dbSqlSessionFactory.getDatabaseSchema(); } String databaseType = dbSqlSessionFactory.getDatabaseType(); if (DbSqlSessionFactory.POSTGRES.equals(databaseType)) { tableName = tableName.toLowerCase(); } try { tables = databaseMetaData.getTables(this.connectionMetadataDefaultCatalog, schema, tableName, JDBC_METADATA_TABLE_TYPES); return tables.next(); } finally { if (tables != null) { tables.close(); } } } catch (Exception e) { throw LOG.checkDatabaseTableException(e); } }
@Override public Object execute(CommandContext commandContext) { try { transactionIsolation[0] = commandContext.getDbSqlSession().getSqlSession().getConnection().getTransactionIsolation(); } catch (SQLException e) { } return null; } });
tableNames = getTablesPresentInOracleDatabase(); } else { Connection connection = getSqlSession().getConnection();
public Object execute(CommandContext commandContext) { // PRINT THE TABLE NAMES TO CHECK IF WE CAN USE METADATA INSTEAD // THIS IS INTENDED FOR TEST THAT SHOULD RUN ON OUR QA INFRASTRUCTURE TO SEE IF METADATA // CAN BE USED INSTEAD OF PERFORMING A QUERY THAT MIGHT FAIL try { SqlSession sqlSession = commandContext.getSession(DbSqlSession.class).getSqlSession(); ResultSet tables = sqlSession.getConnection().getMetaData().getTables(null, null, null, null); while (tables.next()) { ResultSetMetaData resultSetMetaData = tables.getMetaData(); int columnCount = resultSetMetaData.getColumnCount(); for (int i=1; i<=columnCount; i++) { LOG.info("result set column "+i+" | "+resultSetMetaData.getColumnName(i)+" | "+resultSetMetaData.getColumnLabel(i)+" | "+tables.getString(i)); } LOG.info("-------------------------------------------------------"); } } catch (Exception e) { e.printStackTrace(); } return null; } });
tableNames = getTablesPresentInOracleDatabase(); } else { Connection connection = getSqlSession().getConnection();
DatabaseMetaData metaData = getDbSqlSession() .getSqlSession() .getConnection() .getMetaData();
DatabaseMetaData metaData = getDbSqlSession() .getSqlSession() .getConnection() .getMetaData();
@Test public void testTransactionIsolationLevelOnConnection() { ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration(); SqlSession sqlSession = processEngineConfiguration.getDbSqlSessionFactory() .getSqlSessionFactory() .openSession(); try { int transactionIsolation = sqlSession.getConnection().getTransactionIsolation(); assertEquals("TransactionIsolationLevel for connection is " + transactionIsolation + " instead of " + Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_READ_COMMITTED, transactionIsolation); } catch (SQLException e) { e.printStackTrace(); } } }