SQL数据类型NUMERIC

SQL数据类型NUMERIC

本文介绍了什么Java数据类型对应于Oracle SQL数据类型NUMERIC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Oracle JDBC驱动程序为Oracle SQL数据类型分配了哪种Java数据类型 NUMERIC ?这是否会随着 NUMERIC 类型的大小而变化?

What Java data type does the Oracle JDBC driver assign to the Oracle SQL data type NUMERIC? Does this vary with the size of the NUMERIC type?

推荐答案

As其他人已经说过:驱动程序将所有内容映射到BigDecimal,即使它被定义为NUMBER(38)(可以映射到BigInteger)

As others have already said: the driver maps everything to BigDecimal, even if it's defined as NUMBER(38) (which could be mapped to BigInteger)

但它很容易找到出了什么驱动程序映射。只需在ResultSet的列上执行getObject(),然后查看驱动程序生成的类。

But it's pretty easy to find out what the driver maps. Simply do a getObject() on the column of the ResultSet and see which class the driver generated.

类似于:


ResultSet rs = statement.executeQuery("select the_number_column from the_table");
if (rs.next())
{
  Object o = rs.getObject(1);
  System.out.println("Class: " + o.getClass().getName());
}

这篇关于什么Java数据类型对应于Oracle SQL数据类型NUMERIC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 23:08