今天在写程序的时候发现了 dbutils 的一个这样的问题,由于 dbutils 在做表到对象的映射时要求列名和对象的属性名必须一致,例如列名是 userid ,那么属性名也必须是 userid ,但很多时候,我们在编写类的时候,希望能改个属性名,例如是 user 而不是 userid ,这个时候我们这样来写SQL 语句:SELECT userid AS user FROM osc_users然后你会发现根本无法读取到 userid 字段的值,找到了 dbutils 的源码发现它用的是 getColumnName 来获取表的列名,而这个方法对 SQL 语句通过 AS 来修改列名的就无效,在JDK文档中有这么一个方法:getColumnLabel ,该方法在 JDK文档中的描述如下:Gets the designated column's suggested title for use in printouts and displays. The suggested title is usually specified by the SQL AS clause. If a SQL AS is not specified, the value returned from getColumnLabel will be the same as the value returned by the getColumnName method.因此我们需要将 dbutils 中所有用到 getColumnName 的地方都改成 getColumnLabel 即可。本人已经修改好并打包,下载地址是:http://www.oschina.net/project/284