Menu

#145 java.lang.Double returned instead of java.lang.BigDecimal for NUMERIC(10,2) field

open
nobody
None
5
2012-04-14
2012-04-14
Jira Trac
No

For the table:

CREATE TABLE orders ( o_id INTEGER AUTO_INCREMENT NOT NULL, o_no VARCHAR(200) NOT NULL, dt_id CHARACTER(1) NOT NULL,
dt_price_at_date NUMERIC(10,2) NOT NULL, u_id INTEGER NOT NULL, o_date DATE NOT NULL, PRIMARY KEY (o_id), UNIQUE (o_no) );

the following matching results:

private Integer oId;
private String oNo;
private String dtId;
private Double dtPriceAtDate;
private Integer uId;
private java.util.Date oDate;
private Integer sumAmount;
private Double sumOv;
private Double sumPz;
private String osStatus;

dtPriceAtDate is Double instead of BigDecimal. You can verify this with the code attached (dba/test user/pass, utils database, orders table):

ResultSet rs = stmt.executeQuery(SELECT * FROM orders);
ResultSetMetaData rsmd = rs.getMetaData();
String className = rsmd.getColumnClassName(4);

System.out.println(className);

The reason is that: http://cubrid.svn.sourceforge.net/viewvc/cubrid/cubrid/branches/RB-8.4.0/src/jdbc/cubrid/jdbc/jci/UColumnInfo.java?revision=5207view=markup
case UUType.U_TYPE_NUMERIC:
if (UJCIUtil.isMysqlMode(this.getClass())) {
return java.math.BigDecimal;
}
return java.lang.Double;

Returns java.lang.Double always instead of java.lang.BigDecimal. (The same problem exists within the 8.4.1 version also)

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.