如何输入小数或双数?我想如果我输入.56它会在数据库中保存为.56而不是1,因为它的四舍五入并且我想忽略舍入...
这是servlet,我有豆子,它也设置为加倍;我也尝试过DecimalFormat,但仍然没有工作,或者我只是不知道如何使用它。
neutrophils = rs.getInt("neutrophils");
monocytes = rs.getInt("monocytes");
eosinophils = rs.getInt("eosinophils");
basophils = rs.getInt("basophils");
lymphocytes = rs.getInt("lymphocytes");
total= (neutrophils + monocytes + eosinophils + eosinophils + basophils + lymphocytes);
我这样做,我将datatype的值更改为VARCHAR,但错误是java.lang.NullPointerException;那是为什么?
neutrophils = Double.parseDouble(rs.getString("neutrophils"));
monocytes = Double.parseDouble(rs.getString("monocytes"));
eosinophils = Double.parseDouble(rs.getString("eosinophils"));
basophils = Double.parseDouble(rs.getString("basophils"));
lymphocytes = Double.parseDouble(rs.getString("lymphocytes"));
bands = (neutrophils + monocytes + eosinophils + eosinophils + basophils + lymphocytes);
答案 0 :(得分:0)
如果rs
为ResultSet
,您只需使用rs.getDouble
。如果由于某种原因您不想使用它,请将结果作为String获取,然后转换
Double.parseDouble(rs.getString(ColumnLabel));