I'm trying the use reflection to invoke a method that has a java.sql.Connection as argument.
public void setAndValidateSessionUUID(java.lang.String, java.sql.Connection);
I am on a Websphere 7 context using a jndi path to retrieve the data source and it's connection.
private java.sql.Connection connection;
Context ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup(this.DataSourceJNDIPath);
this.connection = dataSource.getConnection();
I have the following piece of code to retrieve the method using reflection
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... args) throws SecurityException, NoSuchMethodException {
return clazz.getMethod(methodName, args);
}
But when I try to retrieve the method it gives me the following error:
java.lang.NoSuchMethodException: setAndValidateSessionUUID(java.lang.String, com.ibm.ws.rsadapter.jdbc.WSJdbcConnection)
I have no problem executing the method without reflection but using it I can't retrieve the method.
Any ideas?
The server returns proxy objects, which you can observe via dataSource.getClass(). On WAS 8.0 and later, you can use the java.sql.Wrapper APIs to call vendor-specific APIs, but on WAS 7.0 and later, you'll need to use WSCallHelper.jdbcCall.