|
|
|
@ -16,6 +16,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.jdbc.datasource; |
|
|
|
package org.springframework.jdbc.datasource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.lang.reflect.Method; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
@ -141,7 +142,7 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter |
|
|
|
getTargetDataSource() + "], using ConnectionSpec [" + connSpec + "]"); |
|
|
|
getTargetDataSource() + "], using ConnectionSpec [" + connSpec + "]"); |
|
|
|
} |
|
|
|
} |
|
|
|
// Create Connection through invoking WSDataSource.getConnection(JDBCConnectionSpec)
|
|
|
|
// Create Connection through invoking WSDataSource.getConnection(JDBCConnectionSpec)
|
|
|
|
Connection con = (Connection) ReflectionUtils.invokeJdbcMethod( |
|
|
|
Connection con = (Connection) invokeJdbcMethod( |
|
|
|
this.wsDataSourceGetConnectionMethod, obtainTargetDataSource(), connSpec); |
|
|
|
this.wsDataSourceGetConnectionMethod, obtainTargetDataSource(), connSpec); |
|
|
|
Assert.state(con != null, "No Connection"); |
|
|
|
Assert.state(con != null, "No Connection"); |
|
|
|
return con; |
|
|
|
return con; |
|
|
|
@ -163,21 +164,40 @@ public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter |
|
|
|
protected Object createConnectionSpec(@Nullable Integer isolationLevel, @Nullable Boolean readOnlyFlag, |
|
|
|
protected Object createConnectionSpec(@Nullable Integer isolationLevel, @Nullable Boolean readOnlyFlag, |
|
|
|
@Nullable String username, @Nullable String password) throws SQLException { |
|
|
|
@Nullable String username, @Nullable String password) throws SQLException { |
|
|
|
|
|
|
|
|
|
|
|
Object connSpec = ReflectionUtils.invokeJdbcMethod(this.newJdbcConnSpecMethod, null); |
|
|
|
Object connSpec = invokeJdbcMethod(this.newJdbcConnSpecMethod, null); |
|
|
|
Assert.state(connSpec != null, "No JDBCConnectionSpec"); |
|
|
|
Assert.state(connSpec != null, "No JDBCConnectionSpec"); |
|
|
|
if (isolationLevel != null) { |
|
|
|
if (isolationLevel != null) { |
|
|
|
ReflectionUtils.invokeJdbcMethod(this.setTransactionIsolationMethod, connSpec, isolationLevel); |
|
|
|
invokeJdbcMethod(this.setTransactionIsolationMethod, connSpec, isolationLevel); |
|
|
|
} |
|
|
|
} |
|
|
|
if (readOnlyFlag != null) { |
|
|
|
if (readOnlyFlag != null) { |
|
|
|
ReflectionUtils.invokeJdbcMethod(this.setReadOnlyMethod, connSpec, readOnlyFlag); |
|
|
|
invokeJdbcMethod(this.setReadOnlyMethod, connSpec, readOnlyFlag); |
|
|
|
} |
|
|
|
} |
|
|
|
// If the username is empty, we'll simply let the target DataSource
|
|
|
|
// If the username is empty, we'll simply let the target DataSource
|
|
|
|
// use its default credentials.
|
|
|
|
// use its default credentials.
|
|
|
|
if (StringUtils.hasLength(username)) { |
|
|
|
if (StringUtils.hasLength(username)) { |
|
|
|
ReflectionUtils.invokeJdbcMethod(this.setUserNameMethod, connSpec, username); |
|
|
|
invokeJdbcMethod(this.setUserNameMethod, connSpec, username); |
|
|
|
ReflectionUtils.invokeJdbcMethod(this.setPasswordMethod, connSpec, password); |
|
|
|
invokeJdbcMethod(this.setPasswordMethod, connSpec, password); |
|
|
|
} |
|
|
|
} |
|
|
|
return connSpec; |
|
|
|
return connSpec; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
private static Object invokeJdbcMethod(Method method, @Nullable Object target, @Nullable Object... args) |
|
|
|
|
|
|
|
throws SQLException { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
return method.invoke(target, args); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (IllegalAccessException ex) { |
|
|
|
|
|
|
|
ReflectionUtils.handleReflectionException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (InvocationTargetException ex) { |
|
|
|
|
|
|
|
if (ex.getTargetException() instanceof SQLException) { |
|
|
|
|
|
|
|
throw (SQLException) ex.getTargetException(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ReflectionUtils.handleInvocationTargetException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
throw new IllegalStateException("Should never get here"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|