This question deals with QueryRunner. I understand that we have created an instance of QueryRunner named "run." However, the arguments given to the query method are throwing me off a bit due to the multiple parentheses and because it doesn't appear to be the same argument passing I am used to.
Can someone please explain to me what exactly is happening in this line:
A simple, step, by step explanation will be helpful.
Line 1. Run this SQL statement and return me the result as a List.
Line 3. Mr. BeanListHandler, you know what to do with results that are in the form of lists, so please handle this result (How? I'm not too sure)
Line 4. Query parameters.... I don't get this part. How do the parameters exactly correspond to the data? What is the ordering? Can you give an example using this code using made-up data?
Can you please explain this to me in very simple terms? Thanks
I've never used this API, so my understanding is based on what the documentation says.
QueryRunner#query: executes the given SELECT SQL query and returns a result object [using replacement parameters].
ResultSetHandler: implementations of this interface convert ResultSets into other objects.
BeanListHandler: implementation [of ResultSetHandler] that converts a ResultSet into a List of beans.
The BeanListHandler takes the rows from the ResultSet and converts them in to beans. In your example, the beans are of type Ret41Data.
The query parameters are the values which are substituted in the prepared statement which was created based on the SQL statement.
For example, if the SQL statement was:
SELECT ticket_number, issuance_date FROM overdue_fines WHERE plate_number=? AND province_code=?
then the query parameters might look something like:
and the bean might be resemble:
The the usage could be something like:
I've only looked at this API for a few minutes, so don't take everything to be 100% correct, but I think the concepts are correct.
Maybe someone who has worked with this API before can provide more information.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop