问题描述
我目前正在使用HSQLDB保存Java数据.在这些数据中,有一些Double,其中一些可以具有NaN
的值(在javadoc中描述为0.0/0.0
). HSQLDB知道如何处理PreparedStatement
的setDouble
和setFloat
中的这些值.问题是,我必须使用Statement
对象,而不是预编译的存储过程,而我只是找不到使它工作的方法.
如果您有最小的提示,那将是最受欢迎的:)
谢谢.
I'm currently using HSQLDB to save java data. Within theses datas, there are some Double, and some of them can be of values of NaN
(described as 0.0/0.0
in the javadoc). HSQLDB know how to handle these values in setDouble
and setFloat
of PreparedStatement
. The thing is, I have to use a Statement
object, not a precompiled stored procedure, and I just can't find a way to make it work.
If you had the tinyest hint, it would be most welcome :)
Thanks.
这是我正在使用的一堆代码:
EDIT : Here's the bunch of code I'm using :
stmt.executeUpdate("insert into Mesh(Id, name, dimension, meshtype, totalVolume, NumberOfCoarseCell) values (identity(), "
+ "'" + name_ + "',"
+ dimension_ + "," // this value can be NaN
+ "'" + type_.toString() + "',"
+ totalVolume_ + "," // this value can be NaN
+ numberOfCoarseCells_ + ")");
推荐答案
使用HSQLDB 1.8.x,您可以将(0.0e1/0.0e1)用作返回NaN的表达式.
With HSQLDB 1.8.x you can use (0.0e1/0.0e1) as an expression that returns NaN.
例如:
create table t (d double)
insert into t values (0.0e1/0.0e1)
对于HSQLDB 2.1及更高版本,必须使用SQL语句指定属性:
For HSQLDB 2.1 and above, an property must be specified with an SQL statement:
SET DATABASE SQL DOUBLE NAN FALSE
或作为连接属性:
hsqldb.double_nan=false
这篇关于HSQLDB语句和Java NaN加倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!