TMS2.0中对DBUtil的改动有哪些?
TMS2.0中对DBUtil的改动有哪些?
1. 改动类:org.apache.commons.dbutils.QueryRunner
添加方法:
1.public Object query(Connection conn,String sql,Object[] params,ResultSetHandler rsh,int startPos, int count) throws SQLException
2.public Object query(String sql, Object param, ResultSetHandler rsh,int startPos,int count) throwsSQLException
3.public Object query(Connection conn, String sql, ResultSetHandler rsh,int startPos,int count) throwsSQLException
4.public Object query(String sql, Object[] params, ResultSetHandler rsh,int startPos,int count) throwsSQLException
以上方法主要用于添加分页支持。
2. 改动类:org.apache.commons.dbutils.RowProcessor(接口)
添加方法:
1.public List toBeanList(ResultSet rs, Class type,int startPos,int count) throws SQLException
用于支持分页查询操作。
3. 改动类:org.apache.commons.dbutils.BasicRowProcessor
添加方法:
1.public List toBeanList(ResultSet rs, Class type, int startPos, int count) throws SQLException
用于支持分页。
修改方法:
1.private Object createBean(ResultSet rs,Class type,PropertyDescriptor[] props,int[] columnToProperty,int cols) throws SQLException
修改部分(添加):
else if(value == null){
}
else if (propType == java.sql.Date.class) {
value = rs.getDate(i);
}
else if (propType == java.util.Date.class) {
value = rs.getDate(i);
}
else if (propType == java.sql.Timestamp.class){
value = rs.getTimestamp(i);
}
else if (propType == org.apache.struts.upload.FormFile.class){
//to do.
}
以上用于支持新的类型。
4. 改动类:org.apache.commons.dbutils.ResultSetHandler(接口)
添加方法:
1.public Object handle(ResultSet rs,int startPos,int count) throws SQLException
用于支持分页。
5. 改动类:org.apache.commons.dbutils.handlers.ArrayHandler,
org.apache.commons.dbutils.handlers.BeanHandler,
org.apache.commons.dbutils.handlers.MapHandler,
org.apache.commons.dbutils.handlers.ScalarHandler
改动:
1. 添加public Object handle(ResultSet rs,int startPos,int count) throws SQLException方法,
直接调用public Object handle(ResultSet rs) throws SQLException,忽略后面2个参数。
6. 改动类:org.apache.commons.dbutils.handlers.ArrayListHandler,
org.apache.commons.dbutils.handlers.BeanListHandler,
org.apache.commons.dbutils.handlers.MapListHandler
改动:
1. 添加public Object handle(ResultSet rs,int startPos,int count) throws SQLException方法,
实现分页查询。祥见每个类对应的方法。