Using JDBC to connect to the database, the query results are converted to list or map (bloated version): http://my.oschina.net/zhengweishan/blog/484377
This feeling is not very good: then change to the following way:
Public static list<map<string, object>> convertlist (RESULTSET&NBSP;RS) { list<map<string, object>> list = new arraylist <Map<String, Object>> (); try { resultsetmetadata md = rs.getmetadata (); int columncount = md.getcolumncount (); while (Rs.next ()) { map <String, Object> rowData = new HashMap<String, Object> (); for (int i = 1; i <= columncount; i++) { &nbsP;rowdata.put (Md.getcolumnname (i), rs.getobject (i)); } list.add ( RowData); } } catch ( Sqlexception e) { // todo auto-generated catch block e.printstacktrace (); } finally { try { if (rs != null) rs.close (); rs = null; } catch (Sqlexception e) { e.printstacktrace (); }} return list;} Public static map<string, object> convertmap (RESULTSET&NBSP;RS) { Map<String, Object> map = new TreeMap<String, Object> (); try{ ResultSetMetaData md = Rs.getmetadata (); int columncount = Md.getcolumncount (); while (Rs.next ()) { for (int i = 1; i <= columncount; i++) { map.put (Md.getcolumnname (i), rs.getobject (i)); } } } catch (sqlexception e) { e.printstacktrace (); } finally { try { if (rs != null) rs.close (); rs = null; } catch (sqlexception e) { E.printstacktrace (); } return map;}
Using JDBC to connect to the database, the query results are converted to list or map (compact version)