About YMP Framework JDBC Query result set Custom processing method

Source: Internet
Author: User

Final String _sql = "Select U.name as Name, U.age, U.type, U.birth from Ym_user u WHERE u.age >?, U.type =?"; /1. Encapsulates the result set of the SQL query as an array list<object[]> _results = jdbc.opensession (New isessionexecutor<list<object[]> > () {public list<object[]> execute (isession session) throws Operatorexception {return Session.findall (_sql, New Arrayresultsethandler (), new object[] {(), "M"});}); /2. The result set of the SQL query is encapsulated in the form of Map list<map<string, object>> _results = jdbc.opensession (New isessionexecutor<list <map<string, object>>> () {public list<map<string, object>> execute (isession session) Throws Operatorexception {return Session.findall (_sql, New Mapresultsethandler (), new object[] {, "M"});}); The result set traversal methods of/1 and 2 are as follows Resultsethelper _help = Resultsethelper.bind (_results); for (int _idx = 0; _idx < _help.getrowcount (); _i dx++) {System.out.println (_help.getasstring ("name")); System.out.println (_help.getasinteger (2));} 3. Custom result set logging process List<customuser> _results = jdbc.opensession (new isessionexecutor<list<customuser>> () {public List< Customuser> Execute (isession session) throws Operatorexception {return Session.findall (_sql, new Abstractresultsethandler<customuser> () {public void Processrowdata (ResultSet rs, list<customuser> result ) throws Operatorexception, SQLException {customuser _u = new Customuser (); _u.setusername (rs.getstring ("name"));// ... result.add (_u);}, New object[]{18, "M"});});



About YMP Framework JDBC Query result set Custom processing method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.