The method public <T> T query (java.lang.String sql, ResultHandler<RES> handler, Object... parameters) takes a ResultHandler as one of its arguments. You can use an implementation of the ResultHandler interface to supply application logic that transforms a query result into an instance of any Java class.