Class Jdbc41Bridge
- java.lang.Object
-
- org.apache.tomcat.dbcp.dbcp2.Jdbc41Bridge
-
public class Jdbc41Bridge extends Object
Defines bridge methods to JDBC 4.1 (Java 7) methods to allow call sites to operate safely (withoutAbstractMethodError
) when using a JDBC driver written for JDBC 4.0 (Java 6).There should be no need to this kind of code for JDBC 4.2 in Java 8 due to JDBC's use of default methods.
This should probably be moved or at least copied in some form to Apache Commons DbUtils.
- Since:
- 2.6.0
-
-
Constructor Summary
Constructors Constructor Description Jdbc41Bridge()
-
Method Summary
-
-
-
Method Detail
-
abort
public static void abort(Connection connection, Executor executor) throws SQLException
Delegates toConnection.abort(Executor)
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Connection.abort(Executor)
, then callConnection.close()
.- Parameters:
connection
- the receiverexecutor
- SeeConnection.abort(Executor)
.- Throws:
SQLException
- SeeConnection.abort(Executor)
.- See Also:
Connection.abort(Executor)
-
closeOnCompletion
public static void closeOnCompletion(Statement statement) throws SQLException
Delegates toStatement.closeOnCompletion()
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Statement.closeOnCompletion()
, then just check that the connection is closed to then throw an SQLException.- Parameters:
statement
- SeeStatement.closeOnCompletion()
- Throws:
SQLException
- SeeStatement.closeOnCompletion()
- See Also:
Statement.closeOnCompletion()
-
generatedKeyAlwaysReturned
public static boolean generatedKeyAlwaysReturned(DatabaseMetaData databaseMetaData) throws SQLException
Delegates toDatabaseMetaData.generatedKeyAlwaysReturned()
without throwing aAbstractMethodError
.If the JDBC driver does not implement
DatabaseMetaData.generatedKeyAlwaysReturned()
, then return false.- Parameters:
databaseMetaData
- SeeDatabaseMetaData.generatedKeyAlwaysReturned()
- Returns:
- See
DatabaseMetaData.generatedKeyAlwaysReturned()
- Throws:
SQLException
- SeeDatabaseMetaData.generatedKeyAlwaysReturned()
- See Also:
DatabaseMetaData.generatedKeyAlwaysReturned()
-
getNetworkTimeout
public static int getNetworkTimeout(Connection connection) throws SQLException
Delegates toConnection.getNetworkTimeout()
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Connection.getNetworkTimeout()
, then return 0.- Parameters:
connection
- the receiver- Returns:
- See
Connection.getNetworkTimeout()
- Throws:
SQLException
- SeeConnection.getNetworkTimeout()
- See Also:
Connection.getNetworkTimeout()
-
getObject
public static <T> T getObject(ResultSet resultSet, int columnIndex, Class<T> type) throws SQLException
Delegates toResultSet.getObject(int, Class)
without throwing anAbstractMethodError
.If the JDBC driver does not implement
ResultSet.getObject(int, Class)
, then return 0.- Type Parameters:
T
- SeeResultSet.getObject(int, Class)
- Parameters:
resultSet
- SeeResultSet.getObject(int, Class)
columnIndex
- SeeResultSet.getObject(int, Class)
type
- SeeResultSet.getObject(int, Class)
- Returns:
- See
ResultSet.getObject(int, Class)
- Throws:
SQLException
- SeeResultSet.getObject(int, Class)
- See Also:
ResultSet.getObject(int, Class)
-
getObject
public static <T> T getObject(ResultSet resultSet, String columnLabel, Class<T> type) throws SQLException
Delegates toResultSet.getObject(String, Class)
without throwing anAbstractMethodError
.- Type Parameters:
T
- SeeResultSet.getObject(String, Class)
- Parameters:
resultSet
- SeeResultSet.getObject(String, Class)
columnLabel
- SeeResultSet.getObject(String, Class)
type
- SeeResultSet.getObject(String, Class)
- Returns:
- See
ResultSet.getObject(String, Class)
- Throws:
SQLException
- SeeResultSet.getObject(String, Class)
- See Also:
ResultSet.getObject(int, Class)
-
getParentLogger
public static Logger getParentLogger(CommonDataSource commonDataSource) throws SQLFeatureNotSupportedException
Delegates toCommonDataSource.getParentLogger()
without throwing anAbstractMethodError
.If the JDBC driver does not implement
CommonDataSource.getParentLogger()
, then return null.- Parameters:
commonDataSource
- SeeCommonDataSource.getParentLogger()
- Returns:
- See
CommonDataSource.getParentLogger()
- Throws:
SQLFeatureNotSupportedException
- SeeCommonDataSource.getParentLogger()
-
getPseudoColumns
public static ResultSet getPseudoColumns(DatabaseMetaData databaseMetaData, String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException
Delegates toDatabaseMetaData.getPseudoColumns(String, String, String, String)
without throwing aAbstractMethodError
.If the JDBC driver does not implement
DatabaseMetaData.getPseudoColumns(String, String, String, String)
, then return null.- Parameters:
databaseMetaData
- the receivercatalog
- SeeDatabaseMetaData.getPseudoColumns(String, String, String, String)
schemaPattern
- SeeDatabaseMetaData.getPseudoColumns(String, String, String, String)
tableNamePattern
- SeeDatabaseMetaData.getPseudoColumns(String, String, String, String)
columnNamePattern
- SeeDatabaseMetaData.getPseudoColumns(String, String, String, String)
- Returns:
- See
DatabaseMetaData.getPseudoColumns(String, String, String, String)
- Throws:
SQLException
- SeeDatabaseMetaData.getPseudoColumns(String, String, String, String)
- See Also:
DatabaseMetaData.getPseudoColumns(String, String, String, String)
-
getSchema
public static String getSchema(Connection connection) throws SQLException
Delegates toConnection.getSchema()
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Connection.getSchema()
, then return null.- Parameters:
connection
- the receiver- Returns:
- null for a JDBC 4 driver or a value per
Connection.getSchema()
. - Throws:
SQLException
- SeeConnection.getSchema()
.- See Also:
Connection.getSchema()
-
isCloseOnCompletion
public static boolean isCloseOnCompletion(Statement statement) throws SQLException
Delegates toStatement.isCloseOnCompletion()
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Statement.isCloseOnCompletion()
, then just check that the connection is closed to then throw an SQLException.- Parameters:
statement
- SeeStatement.isCloseOnCompletion()
- Returns:
- See
Statement.isCloseOnCompletion()
- Throws:
SQLException
- SeeStatement.isCloseOnCompletion()
- See Also:
Statement.closeOnCompletion()
-
setNetworkTimeout
public static void setNetworkTimeout(Connection connection, Executor executor, int milliseconds) throws SQLException
Delegates toConnection.setNetworkTimeout(Executor, int)
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Connection.setNetworkTimeout(Executor, int)
, then do nothing.- Parameters:
connection
- the receiverexecutor
- SeeConnection.setNetworkTimeout(Executor, int)
milliseconds
-Connection.setNetworkTimeout(Executor, int)
- Throws:
SQLException
-Connection.setNetworkTimeout(Executor, int)
- See Also:
Connection.setNetworkTimeout(Executor, int)
-
setSchema
public static void setSchema(Connection connection, String schema) throws SQLException
Delegates toConnection.setSchema(String)
without throwing anAbstractMethodError
.If the JDBC driver does not implement
Connection.setSchema(String)
, then do nothing.- Parameters:
connection
- the receiverschema
- SeeConnection.setSchema(String)
.- Throws:
SQLException
- SeeConnection.setSchema(String)
.- See Also:
Connection.setSchema(String)
-
-