0

关于rs.getObject("fieldName")的问题

 3 months ago
source link: https://www.jdon.com/34861.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

关于rs.getObject("fieldName")的问题

昨天在项目上用了jdon框架中的JdbcTemp.java和JdbcUtil.java两个类,想借此简化jdbc代码的编写,可是最后发现有点小问题存在,原来rs.getObject("fielName")所得到的数据类型和数据库的驱动有关,同样是数据库中的Int类型的字段,在sqlServer2000的驱动中(Integer)rs.getObject("age"),类型转换没有问题,可是用了sqlServer2005的驱动后发现抛出ClassCastException异常,最后一查,原来rs.getObject("age"),取出的类型是Short类型而不是Integer类型。因为我们的项目中用到了数据库集群的技术,有的用的是2000的驱动,有的用的是2005的驱动,所以最后还是不得不换下jdbcTemp.java和JdbcTemp.java这两个类
[该贴被ybzshizds于2008-11-03 08:50修改过]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK