SOLID Table 错误 13037:非法的 DOUBLE PREC 常量

SOLID Table Error 13037: Illegal DOUBLE PREC constant

我在尝试使用我的 Java JDBC 代码向 SolidDB 添加记录时遇到以下错误。

抛出异常的方法如下:

    public void addData(User data) {
    Connection conn = null;
    try {
        conn = dataSource.getConnection();
        if (conn == null || conn.isClosed()) {
            throw new RuntimeException("Could not open connection");
        }
        String query="INSERT INTO USER "
                + "(ID, NAME, PASSWORD, ENABLED, REQUIRE_RESET)"
                + "VALUES (?, ?, ?, ?, ?);";

        PreparedStatement ps = conn.prepareStatement(query);
        // "ID" column is INTEGER, and partition field in UserData is int.
        ps.setString(1, data.getId());
        ps.setString(2, data.getName());
        ps.setString(3, data.getPassword());
        // "ENABLED" column is INTEGER, and enabled field in UserData is boolean.
        ps.setInt(4, data.isEnabled()? 1:0); 
        ps.setString(5, data.isRequireReset()?"Y":"N");
        if (ps.executeUpdate() < 1) {
            throw new RuntimeException("Could not save User, executeUpdate() returned a value < 1");
        }

    } Catch (SQLException e) {
        throw new DataLayerException("Could not save the User Data.", e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException e) {
            }
        }
    }
}

我已经尝试过直接硬编码值,但仍然失败。 如果我从插入语句中删除 "ID" & "ENABLED" 列,插入将成功。

提前致谢。

PreparedStatement 索引为 1-based (see also setXX javadoc)。因为您使用 0,并且驱动程序没有警告您,所以一切都是 "shifted" 导致的问题。

修复:

ps.setString(1, data.getId());
ps.setString(2, data.getName());
ps.setString(3, data.getPassword());
ps.setInt(4, data.isEnabled()? 1:0); 
ps.setString(5, data.isRequireReset()?"Y":"N");

最后我得到了解决方案,这是因为一个愚蠢的语法错误。 当我去掉最后的分号时,它起作用了!