读取oracle错误后的jython浮点精度
我在读取oracle的浮动时遇到问题。 我有以下片段:读取oracle错误后的jython浮点精度,oracle,jython,Oracle,Jython,我在读取oracle的浮动时遇到问题。 我有以下片段: sqlstr='select prio from tabletest' statement = None if connection is not None: try: statement = connection.prepareStatement(sqlstr) if connection is not None: rs = statement.executeQuery()
sqlstr='select prio from tabletest'
statement = None
if connection is not None:
try:
statement = connection.prepareStatement(sqlstr)
if connection is not None:
rs = statement.executeQuery()
if rs is not None:
#statement.closeOnComplete()
while (rs.next()):
NWW = rs.getFloat(1)
print (NWW)
rs.close()
else:
statement.close()
except:
pass
finally:
connection.close()
这让我明白:
0.5
0.5
0.5
0.20000000298
0.5
0.990000009537
0.5
0.5
0.699999988079
但我在数据库中的实际数据如下所示:
0,5
0,5
0,5
0,2
0,5
0,99
0,5
0,5
0,7
db的定义如下:
CREATE TABLE "SYSTEM"."tabletest"
( "NWW" NUMBER(12,8)
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "SYSTEM" ;
如您所见,只有当prio=0.5时,浮点才是精确的。。。是否有任何选项可以设置浮动是精确的
谢谢,
E.。。。有点尴尬,但rs.getDouble(1)解决了我的问题。:)