I've a SQL query stored in SQLQUERY column of the database and I am using the following SQL statement to retrieve it : SELECT SQLQUERY FROM MYTABLE WHERE dataid = ? as shown below in my try block (only part of code is shown for brevity purpose)
So, in the code above, the resultset object rs is holding the value of the `SQLQUERY` column corresponding to the dataid. Say for example, the value retrieved is "SELECT * FROM TABLE2 WHERE empID = 101".
How can I run the value (which is the SQL) so that the result set object would hold its column values?
Well, actually the ResultSet is holding a collection of zero or more rows, each of which contains a single column. And that column contains a string (I assume) which is an SQL query.
So the first step is to iterate through the ResultSet and get that string out of each of those rows. I expect you already know how to do that, if not then every tutorial ever written about JDBC will have an example very near the beginning.
And once you have a String value which contains an SQL query... I expect you already know how to create a Statement which uses an SQL query, no?
Hope that helps, if it isn't clear now then ask for clarification about the parts you still don't understand.