Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

查询Count时,使用getObject()取数会报异常 #18

Closed
wangda opened this issue Feb 25, 2016 · 1 comment
Closed

查询Count时,使用getObject()取数会报异常 #18

wangda opened this issue Feb 25, 2016 · 1 comment

Comments

@wangda
Copy link
Contributor

wangda commented Feb 25, 2016

现象:
SQL: select count(*) as cnt from tbl;

如果我使用 ResultSet.getLong()getInt()都可以。
但是如果我使用 getObject(),就会报异常:
ShardingJdbcException("Unsupported data type:%s", convertType)

原因:
s-jdbc在聚合Merge时,会根据调用方法的返回值来转换merge的结果,当调用getObject()Number类型结果时,就需要将Number转为Object了,现在s-jdbc直接报不支持的类型。

修改方法:
对于返回类型为Object时,直接将Number值返回。

代码位置:
com/dangdang/ddframe/rdb/sharding/merger/common/ResultSetUtil.java
convertNumberValue方法:
我给增加了

case "java.lang.Object":
              return value;

在我本地测试没有问题了。

@hanahmily
Copy link
Contributor

@wangda 感谢您的bug回复,1.0.1的时候我们会进行修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants