简体   繁体   English

Count()/ sum()的ResultSetMetadata列类型

[英]ResultSetMetadata column types for count()/sum()

In MySQL select: 在MySQL中,选择:

count(BIGINT) returns type=-5 (BigInteger), I expected Long count(BIGINT)返回type = -5(BigInteger),我期望Long

sum(SMALLINT) returns type=3 (BigDecimal), I expected Integer sum(SMALLINT)返回type = 3(BigDecimal),我希望是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. 值-5表示java.sql.Types.BIGINT ,它是Java long的JDBC / SQL等效项,因此完全可以预期该值。

As to why SUM is mapped to 3, or java.sql.DECIMAL , I'm not sure. 至于为什么将SUM映射到3或java.sql.DECIMAL ,我不确定。 It might just be that is what MySQL does when summing not floating-point types. 这可能就是MySQL在对非浮点类型求和时所做的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在执行查询之前获取SQL中的列数? 即ResultSetMetaData以外的其他方式 - How to get column count in SQL before executing the query? i.e. way other than ResultSetMetaData ResultSetMetaData 获取列的默认值 - ResultSetMetaData getting default value of column 根据ResultSetMetaData中的列数在Setter中设置值 - Set value in Setter according to number of column in ResultSetMetaData 如何有效地获取“ AS”列名称,例如ResultSetMetaData? - How to effectively get “AS” column name like ResultSetMetaData? DB2和ResultSetMetaData - 无法获取列名 - DB2 and ResultSetMetaData - Unable to get column name Java ResultSetMetaData返回不正确的列类型 - Java ResultSetMetaData returning an incorrect column type 在不使用ResultSetMetaData的情况下从表中检索列名 - Retrieving column names from a table without using ResultSetMetaData HSQLDB和DBUnit,在SQL查询上使用Allias时无法从ResultSetMetaData中找到列 - HSQLDB & DBUnit, Cannot find column from ResultSetMetaData when using allias on SQL query 如何从JAVA中的ResultSet或ResultSetMetaData对象获取数据库表的主键的列名? - How can I get the column name of the primary key of a Database Table from the ResultSet or ResultSetMetaData object in JAVA? 如何返回Java中指定表的列数、列名、列类型? - How to return the column count, column names, and column types from a specified table in Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM