Java Code Examples for java.sql.DatabaseMetaData#supportsResultSetType()
The following examples show how to use
java.sql.DatabaseMetaData#supportsResultSetType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtractedDatabaseMetaDataImpl.java From lams with GNU General Public License v2.0 | 6 votes |
public Builder apply(DatabaseMetaData databaseMetaData) throws SQLException { connectionCatalogName = databaseMetaData.getConnection().getCatalog(); // NOTE : databaseMetaData.getConnection().getSchema() would require java 1.7 as baseline supportsRefCursors = StandardRefCursorSupport.supportsRefCursors( databaseMetaData ); supportsNamedParameters = databaseMetaData.supportsNamedParameters(); supportsScrollableResults = databaseMetaData.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE ); supportsGetGeneratedKeys = databaseMetaData.supportsGetGeneratedKeys(); supportsBatchUpdates = databaseMetaData.supportsBatchUpdates(); supportsDataDefinitionInTransaction = !databaseMetaData.dataDefinitionIgnoredInTransactions(); doesDataDefinitionCauseTransactionCommit = databaseMetaData.dataDefinitionCausesTransactionCommit(); extraKeywords = parseKeywords( databaseMetaData.getSQLKeywords() ); sqlStateType = SQLStateType.interpretReportedSQLStateType( databaseMetaData.getSQLStateType() ); lobLocatorUpdateCopy = databaseMetaData.locatorsUpdateCopy(); typeInfoSet = new LinkedHashSet<TypeInfo>(); typeInfoSet.addAll( TypeInfo.extractTypeInfo( databaseMetaData ) ); return this; }
Example 2
Source File: ResultSetLiveTest.java From tutorials with MIT License | 6 votes |
@Test public void givenDbConnectionE_whenDBMetaInfo_thenCorrect() throws SQLException { DatabaseMetaData dbmd = dbConnection.getMetaData(); boolean supportsTypeForward = dbmd.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY); boolean supportsTypeScrollSensitive = dbmd.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE); boolean supportsTypeScrollInSensitive = dbmd.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); boolean supportsCloseCursorsAtCommit = dbmd.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); boolean supportsHoldCursorsAtCommit = dbmd.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT); boolean concurrency4TypeFwdNConcurReadOnly = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); boolean concurrency4TypeFwdNConcurUpdatable = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); boolean concurrency4TypeScrollInSensitiveNConcurUpdatable = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); boolean concurrency4TypeScrollInSensitiveNConcurReadOnly = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); boolean concurrency4TypeScrollSensitiveNConcurUpdatable = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); boolean concurrency4TypeScrollSensitiveNConcurReadOnly = dbmd.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); int rsHoldability = dbmd.getResultSetHoldability(); assertEquals("checking scroll sensitivity and concur updates : ", true, concurrency4TypeScrollInSensitiveNConcurUpdatable); }
Example 3
Source File: JdbcSource.java From datacollector with Apache License 2.0 | 5 votes |
private void supportsScrollableCursor( List<ConfigIssue> issues, Source.Context context, DatabaseMetaData dbMetadata ) throws SQLException { if (!txnColumnName.isEmpty() && !dbMetadata.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) { issues.add(context.createConfigIssue(Groups.CDC.name(), TXN_ID_COLUMN_NAME, JdbcErrors.JDBC_30)); } }
Example 4
Source File: DbConnectionManager.java From Openfire with Apache License 2.0 | 4 votes |
/** * Uses a connection from the database to set meta data information about * what different JDBC drivers and databases support. * * @param con the connection. * @throws SQLException if an SQL exception occurs. */ private static void setMetaData(Connection con) throws SQLException { DatabaseMetaData metaData = con.getMetaData(); // Supports transactions? transactionsSupported = metaData.supportsTransactions(); // Supports subqueries? subqueriesSupported = metaData.supportsCorrelatedSubqueries(); // Supports scroll insensitive result sets? Try/catch block is a // workaround for DB2 JDBC driver, which throws an exception on // the method call. try { scrollResultsSupported = metaData.supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE); } catch (Exception e) { scrollResultsSupported = false; } // Supports batch updates batchUpdatesSupported = metaData.supportsBatchUpdates(); // Set defaults for other meta properties streamTextRequired = false; maxRowsSupported = true; fetchSizeSupported = true; identifierQuoteString = metaData.getIdentifierQuoteString(); // Get the database name so that we can perform meta data settings. String dbName = metaData.getDatabaseProductName().toLowerCase(); String driverName = metaData.getDriverName().toLowerCase(); // Oracle properties. if (dbName.indexOf("oracle") != -1) { databaseType = DatabaseType.oracle; streamTextRequired = true; scrollResultsSupported = false; /* TODO comment and test this, it should be supported since 10g */ // The i-net AUGURO JDBC driver if (driverName.indexOf("auguro") != -1) { streamTextRequired = false; fetchSizeSupported = true; maxRowsSupported = false; } } // Postgres properties else if (dbName.indexOf("postgres") != -1) { databaseType = DatabaseType.postgresql; // Postgres blows, so disable scrolling result sets. scrollResultsSupported = false; fetchSizeSupported = false; } // Interbase properties else if (dbName.indexOf("interbase") != -1) { databaseType = DatabaseType.interbase; fetchSizeSupported = false; maxRowsSupported = false; } // SQLServer else if (dbName.indexOf("sql server") != -1) { databaseType = DatabaseType.sqlserver; // JDBC driver i-net UNA properties if (driverName.indexOf("una") != -1) { fetchSizeSupported = true; maxRowsSupported = false; } } // MySQL properties else if (dbName.indexOf("mysql") != -1) { databaseType = DatabaseType.mysql; transactionsSupported = false; /* TODO comment and test this, it should be supported since 5.0 */ } // HSQL properties else if (dbName.indexOf("hsql") != -1) { databaseType = DatabaseType.hsqldb; // scrollResultsSupported = false; /* comment and test this, it should be supported since 1.7.2 */ } // DB2 properties. else if (dbName.indexOf("db2") != 1) { databaseType = DatabaseType.db2; } }