[更新]:修复了查询字段映射bug,导致结果集数量=字段*字段数问题。ls.add(c);应该放到for (int i = 1; i < rsm.getColumnCount() + 1; i++) {}外面。 以前一直用Spring的JdbcTemplate查询数据,JdbcTemplate被封装的及其简单易用。某些时候不太适合使用Spring这样庞大的框架,所以自己封装了个JDBC查询的自动映射类以备后用。实现了一个简单的映射数据库表到实体类数组。 TableMapping.java: /*
* Copyright yz 2016-01-14 Email:
[email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr