for (int i = 0; i < colName.length; i++) {
String colNames = colName[i];
String MethodName = "set" + colNames;
Method[] ms = user.getClass().getMethods();
// System.out.println(ms[i]);
for (Method m : ms) {
if (MethodName.equals(m.getName())) {
m.invoke(user, rs.getObject(colNames));
}
}
}
运行后出错Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.gdcc.other.ORMTest.getUser(ORMTest.java:58)
at com.gdcc.other.ORMTest.main(ORMTest.java:19)请高手帮忙看看,我在线等待!
String colNames = colName[i];
String MethodName = "set" + colNames;
Method[] ms = user.getClass().getMethods();
// System.out.println(ms[i]);
for (Method m : ms) {
if (MethodName.equals(m.getName())) {
m.invoke(user, rs.getObject(colNames));
}
}
}
运行后出错Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.gdcc.other.ORMTest.getUser(ORMTest.java:58)
at com.gdcc.other.ORMTest.main(ORMTest.java:19)请高手帮忙看看,我在线等待!
rs.getObject(colNames)又是什么类型的参数??自己断点一调试便知问题所在
这个我知道啊 我传入的SQL语句中已经将名字改为首字母大写的了!现在断点还是没找出什么来!呜呜!
非法参数异常
我想是你这一句有问题:m.invoke(user, rs.getObject(colNames));
问题应该rs.getObject(colNames),
一般的调用方法是这样Object result = addMethod.invoke(invokeTester, new Object[]{1,2});
即是传入的参数为1,2;
不知我说的是否有参考价值。