No subject


Sat Nov 12 19:29:10 PST 2005


You are trying to use invoke() method as if it were a static
method in class java.lang.reflect.Method.
let me know if i am wrong
gautam

-----Original Message-----
From: Christian Ribeaud [mailto:christian.ribeaud at predict.ch]
Sent: Tuesday, December 12, 2000 2:14 PM
To: advanced-java at xcf.berkeley.edu
Subject: Invoke Method dynamically?


Hi,

I wanted to invoke the PreparedStatement-Interface's setXXX methods
dynamically. I tried the following code but I got an error I do not
understand. What is wrong? I would be very grateful if someone could help
me. Have a nice day.
Regards,

christian

the code:
---------
query = bufferQuery.toString();
// enter the data in the database
String dataType = request.getParameter("dataType");
PreparedStatement pstmt = con.prepareStatement(query);
for (int i = 1;i<=listLen(dataType);i++) {
	String[] args = {Integer.toString(i),
	request.getParameter(listGetAt(newParams.toString(),i))};
	java.lang.reflect.Method.invoke("pstmt.set"
	+ listGetAt(dataType,i),args);
}
pstmt.executeUpdate();
pstmt.close();
================================================================
the error message:
------------------
non-static method invoke(java.lang.Object,java.lang.Object[])
cannot be referenced from a static context
java.lang.reflect.Method.invoke("setString()",args);


---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu


---
To unsubscribe, mail advanced-java-unsubscribe at xcf.berkeley.edu
To get help, mail advanced-java-help at xcf.berkeley.edu



More information about the Advanced-java mailing list