how to invoke Result Set method in java?

156 views Asked by At

ResultSet data_result = dao.getDetails();

Method resultset_method;

resultset_method = data_result.getClass().getMethod("getInt", Integer.class);

it is giving error:

java.lang.NoSuchMethodException: org.apache.commons.dbcp.DelegatingResultSet.getInt(java.lang.Integer)
1

There are 1 answers

6
Evan Knowles On BEST ANSWER

The ResultSet's getInt method has two overloads, one that takes an int for the index and one that takes a String for a column name. You're attempting to retrieve a getInt() method, which indeed does not exist.

You need to supply the types that the method takes - eg, if you were going by name,

resultset_method = data_result.getClass().getMethod("getInt", String.class);