I am trying to find the method of a PreparedStatement (ps):
Method method = ps.getClass().getMethod("setLong", int.class, Class.forName("java.lang.Long"));
method.setAccessible(true);
method.invoke(ps, fieldIndex, value);
but it isn't found. I have to use Class.forName("java.lang.Long") instead of Long.class.
For String it works:
Method method = ps.getClass().getMethod("setString", int.class, Class.forName("java.lang.String"));
method.setAccessible(true);
method.invoke(ps, fieldIndex, value);
What am I doing wrong? Any idea? Is the namespace of Long wrong?
ps.setLong(fieldIndex, value).setAccessiblecall indicates that those methods are not visible to the calling code. But they are, so maybe MrSct just thought they weren't :/set…method you will use, the driver will attempt to convert the argument to the target type. It would be very strange, if you can’t just usesetObject(int,Object)orsetObject(int,Object,type:int)…