Java Code Examples for java.sql.DatabaseMetaData#supportsNamedParameters()

The following examples show how to use java.sql.DatabaseMetaData#supportsNamedParameters() . 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 vote down vote up
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: preparedData.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
public static boolean supportsNamedParameters(Connection _conn) {
	// If the driver supports named parameters then return true
	try {
		DatabaseMetaData dbmd = _conn.getMetaData();
		if (dbmd.supportsNamedParameters())
			return true;
	} catch (Throwable t) {
		// The supportsNamedParameters() method was added in JDBC 3.0 (JDK 1.4) so
		// ignore exceptions that might be thrown by older drivers. For example,
		// with older JTurbo drivers the above call causes a java.lang.AbstractMethodError.
	}

	// Must not support named parameters so return false
	return false;
}
 
Example 3
Source File: Dialect.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Override the DatabaseMetaData#supportsNamedParameters()
 *
 * @return boolean
 *
 * @throws SQLException Accessing the DatabaseMetaData can throw it.  Just re-throw and Hibernate will handle.
 */
public boolean supportsNamedParameters(DatabaseMetaData databaseMetaData) throws SQLException {
	return databaseMetaData != null && databaseMetaData.supportsNamedParameters();
}