Java Code Examples for org.springframework.util.ReflectionUtils#invokeJdbcMethod()
The following examples show how to use
org.springframework.util.ReflectionUtils#invokeJdbcMethod() .
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: WebSphereDataSourceAdapter.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a WebSphere {@code JDBCConnectionSpec} object for the given characteristics. * <p>The default implementation uses reflection to apply the given settings. * Can be overridden in subclasses to customize the JDBCConnectionSpec object * (<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/rsadapter/JDBCConnectionSpec.html">JDBCConnectionSpec javadoc</a>; * <a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0404_tang/0404_tang.html">IBM developerWorks article</a>). * @param isolationLevel the isolation level to apply (or {@code null} if none) * @param readOnlyFlag the read-only flag to apply (or {@code null} if none) * @param username the username to apply ({@code null} or empty indicates the default) * @param password the password to apply (may be {@code null} or empty) * @throws SQLException if thrown by JDBCConnectionSpec API methods * @see com.ibm.websphere.rsadapter.JDBCConnectionSpec */ protected Object createConnectionSpec( Integer isolationLevel, Boolean readOnlyFlag, String username, String password) throws SQLException { Object connSpec = ReflectionUtils.invokeJdbcMethod(this.newJdbcConnSpecMethod, null); if (isolationLevel != null) { ReflectionUtils.invokeJdbcMethod(this.setTransactionIsolationMethod, connSpec, isolationLevel); } if (readOnlyFlag != null) { ReflectionUtils.invokeJdbcMethod(this.setReadOnlyMethod, connSpec, readOnlyFlag); } // If the username is empty, we'll simply let the target DataSource // use its default credentials. if (StringUtils.hasLength(username)) { ReflectionUtils.invokeJdbcMethod(this.setUserNameMethod, connSpec, username); ReflectionUtils.invokeJdbcMethod(this.setPasswordMethod, connSpec, password); } return connSpec; }
Example 2
Source File: WebSphereDataSourceAdapter.java From effectivejava with Apache License 2.0 | 6 votes |
/** * Create a WebSphere {@code JDBCConnectionSpec} object for the given charateristics. * <p>The default implementation uses reflection to apply the given settings. * Can be overridden in subclasses to customize the JDBCConnectionSpec object * (<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/rsadapter/JDBCConnectionSpec.html">JDBCConnectionSpec javadoc</a>; * <a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0404_tang/0404_tang.html">IBM developerWorks article</a>). * @param isolationLevel the isolation level to apply (or {@code null} if none) * @param readOnlyFlag the read-only flag to apply (or {@code null} if none) * @param username the username to apply ({@code null} or empty indicates the default) * @param password the password to apply (may be {@code null} or empty) * @throws SQLException if thrown by JDBCConnectionSpec API methods * @see com.ibm.websphere.rsadapter.JDBCConnectionSpec */ protected Object createConnectionSpec( Integer isolationLevel, Boolean readOnlyFlag, String username, String password) throws SQLException { Object connSpec = ReflectionUtils.invokeJdbcMethod(this.newJdbcConnSpecMethod, null); if (isolationLevel != null) { ReflectionUtils.invokeJdbcMethod(this.setTransactionIsolationMethod, connSpec, isolationLevel); } if (readOnlyFlag != null) { ReflectionUtils.invokeJdbcMethod(this.setReadOnlyMethod, connSpec, readOnlyFlag); } // If the username is empty, we'll simply let the target DataSource // use its default credentials. if (StringUtils.hasLength(username)) { ReflectionUtils.invokeJdbcMethod(this.setUserNameMethod, connSpec, username); ReflectionUtils.invokeJdbcMethod(this.setPasswordMethod, connSpec, password); } return connSpec; }
Example 3
Source File: WebSphereDataSourceAdapter.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create a WebSphere {@code JDBCConnectionSpec} object for the given charateristics. * <p>The default implementation uses reflection to apply the given settings. * Can be overridden in subclasses to customize the JDBCConnectionSpec object * (<a href="http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/com.ibm.websphere.javadoc.doc/public_html/api/com/ibm/websphere/rsadapter/JDBCConnectionSpec.html">JDBCConnectionSpec javadoc</a>; * <a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0404_tang/0404_tang.html">IBM developerWorks article</a>). * @param isolationLevel the isolation level to apply (or {@code null} if none) * @param readOnlyFlag the read-only flag to apply (or {@code null} if none) * @param username the username to apply ({@code null} or empty indicates the default) * @param password the password to apply (may be {@code null} or empty) * @throws SQLException if thrown by JDBCConnectionSpec API methods * @see com.ibm.websphere.rsadapter.JDBCConnectionSpec */ protected Object createConnectionSpec( Integer isolationLevel, Boolean readOnlyFlag, String username, String password) throws SQLException { Object connSpec = ReflectionUtils.invokeJdbcMethod(this.newJdbcConnSpecMethod, null); if (isolationLevel != null) { ReflectionUtils.invokeJdbcMethod(this.setTransactionIsolationMethod, connSpec, isolationLevel); } if (readOnlyFlag != null) { ReflectionUtils.invokeJdbcMethod(this.setReadOnlyMethod, connSpec, readOnlyFlag); } // If the username is empty, we'll simply let the target DataSource // use its default credentials. if (StringUtils.hasLength(username)) { ReflectionUtils.invokeJdbcMethod(this.setUserNameMethod, connSpec, username); ReflectionUtils.invokeJdbcMethod(this.setPasswordMethod, connSpec, password); } return connSpec; }
Example 4
Source File: JBossNativeJdbcExtractor.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingResultSet} method. */ @Override public ResultSet getNativeResultSet(ResultSet rs) throws SQLException { if (this.wrappedResultSetClass.isAssignableFrom(rs.getClass())) { return (ResultSet) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingResultSetMethod, rs); } return rs; }
Example 5
Source File: WebSphereDataSourceAdapter.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Builds a WebSphere JDBCConnectionSpec object for the current settings * and calls {@code WSDataSource.getConnection(JDBCConnectionSpec)}. * @see #createConnectionSpec * @see com.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec) */ @Override protected Connection doGetConnection(String username, String password) throws SQLException { // Create JDBCConnectionSpec using current isolation level value and read-only flag. Object connSpec = createConnectionSpec( getCurrentIsolationLevel(), getCurrentReadOnlyFlag(), username, password); if (logger.isDebugEnabled()) { logger.debug("Obtaining JDBC Connection from WebSphere DataSource [" + getTargetDataSource() + "], using ConnectionSpec [" + connSpec + "]"); } // Create Connection through invoking WSDataSource.getConnection(JDBCConnectionSpec) return (Connection) ReflectionUtils.invokeJdbcMethod( this.wsDataSourceGetConnectionMethod, getTargetDataSource(), connSpec); }
Example 6
Source File: WebLogicNativeJdbcExtractor.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via WebLogic's {@code getVendorConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.jdbcExtensionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.getVendorConnectionMethod, con); } return con; }
Example 7
Source File: WebSphereNativeJdbcExtractor.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via WebSphere's {@code getNativeConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.webSphereConnectionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.webSphereNativeConnectionMethod, null, con); } return con; }
Example 8
Source File: WebSphereDataSourceAdapter.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Builds a WebSphere JDBCConnectionSpec object for the current settings * and calls {@code WSDataSource.getConnection(JDBCConnectionSpec)}. * @see #createConnectionSpec * @see com.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec) */ @Override protected Connection doGetConnection(String username, String password) throws SQLException { // Create JDBCConnectionSpec using current isolation level value and read-only flag. Object connSpec = createConnectionSpec( getCurrentIsolationLevel(), getCurrentReadOnlyFlag(), username, password); if (logger.isDebugEnabled()) { logger.debug("Obtaining JDBC Connection from WebSphere DataSource [" + getTargetDataSource() + "], using ConnectionSpec [" + connSpec + "]"); } // Create Connection through invoking WSDataSource.getConnection(JDBCConnectionSpec) return (Connection) ReflectionUtils.invokeJdbcMethod( this.wsDataSourceGetConnectionMethod, getTargetDataSource(), connSpec); }
Example 9
Source File: JBossNativeJdbcExtractor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingResultSet} method. */ @Override public ResultSet getNativeResultSet(ResultSet rs) throws SQLException { if (this.wrappedResultSetClass.isAssignableFrom(rs.getClass())) { return (ResultSet) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingResultSetMethod, rs); } return rs; }
Example 10
Source File: JBossNativeJdbcExtractor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingStatement} method. */ @Override public Statement getNativeStatement(Statement stmt) throws SQLException { if (this.wrappedStatementClass.isAssignableFrom(stmt.getClass())) { return (Statement) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingStatementMethod, stmt); } return stmt; }
Example 11
Source File: JBossNativeJdbcExtractor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.wrappedConnectionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingConnectionMethod, con); } return con; }
Example 12
Source File: WebLogicNativeJdbcExtractor.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via WebLogic's {@code getVendorConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.jdbcExtensionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.getVendorConnectionMethod, con); } return con; }
Example 13
Source File: JBossNativeJdbcExtractor.java From effectivejava with Apache License 2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingStatement} method. */ @Override public Statement getNativeStatement(Statement stmt) throws SQLException { if (this.wrappedStatementClass.isAssignableFrom(stmt.getClass())) { return (Statement) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingStatementMethod, stmt); } return stmt; }
Example 14
Source File: WebSphereDataSourceAdapter.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Builds a WebSphere JDBCConnectionSpec object for the current settings * and calls {@code WSDataSource.getConnection(JDBCConnectionSpec)}. * @see #createConnectionSpec * @see com.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec) */ @Override protected Connection doGetConnection(String username, String password) throws SQLException { // Create JDBCConnectionSpec using current isolation level value and read-only flag. Object connSpec = createConnectionSpec( getCurrentIsolationLevel(), getCurrentReadOnlyFlag(), username, password); if (logger.isDebugEnabled()) { logger.debug("Obtaining JDBC Connection from WebSphere DataSource [" + getTargetDataSource() + "], using ConnectionSpec [" + connSpec + "]"); } // Create Connection through invoking WSDataSource.getConnection(JDBCConnectionSpec) return (Connection) ReflectionUtils.invokeJdbcMethod( this.wsDataSourceGetConnectionMethod, getTargetDataSource(), connSpec); }
Example 15
Source File: JBossNativeJdbcExtractor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingResultSet} method. */ @Override public ResultSet getNativeResultSet(ResultSet rs) throws SQLException { if (this.wrappedResultSetClass.isAssignableFrom(rs.getClass())) { return (ResultSet) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingResultSetMethod, rs); } return rs; }
Example 16
Source File: JBossNativeJdbcExtractor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingStatement} method. */ @Override public Statement getNativeStatement(Statement stmt) throws SQLException { if (this.wrappedStatementClass.isAssignableFrom(stmt.getClass())) { return (Statement) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingStatementMethod, stmt); } return stmt; }
Example 17
Source File: JBossNativeJdbcExtractor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Connection via JBoss' {@code getUnderlyingConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.wrappedConnectionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.getUnderlyingConnectionMethod, con); } return con; }
Example 18
Source File: WebLogicNativeJdbcExtractor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Connection via WebLogic's {@code getVendorConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.jdbcExtensionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.getVendorConnectionMethod, con); } return con; }
Example 19
Source File: WebSphereNativeJdbcExtractor.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieve the Connection via WebSphere's {@code getNativeConnection} method. */ @Override protected Connection doGetNativeConnection(Connection con) throws SQLException { if (this.webSphereConnectionClass.isAssignableFrom(con.getClass())) { return (Connection) ReflectionUtils.invokeJdbcMethod(this.webSphereNativeConnectionMethod, null, con); } return con; }
Example 20
Source File: JdbcMethodUtils.java From compass with Apache License 2.0 | 3 votes |
/** * 通过反射来执行JDBC接口的方法 * @param interfaceClass * @param methodName * @param argTypes * @param target * @param args * @return * @throws SQLException */ public static Object invokeJdbcMethod(Class<?> interfaceClass,String methodName,Class<?>[] argTypes,Object target,Object[] args) throws SQLException { Method method=ClassUtils.getMethodIfAvailable(interfaceClass, methodName, argTypes); if(method == null) { return null; } return ReflectionUtils.invokeJdbcMethod(method, target, args); }