简体   繁体   中英

ResultSetMetadata column types for count()/sum()

In MySQL select:

count(BIGINT) returns type=-5 (BigInteger), I expected Long

sum(SMALLINT) returns type=3 (BigDecimal), I expected Integer

Is there anything that can be done?

The value of -5 indicates java.sql.Types.BIGINT , which is the JDBC/SQL equivalent of a Java long , so this value is entirely expected.

As to why SUM is mapped to 3, or java.sql.DECIMAL , I'm not sure. It might just be that is what MySQL does when summing not floating-point types.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM