我有一个随机生成的问题(千分之几的时间)。
错误 ORA-01722:无效数字是在准备好的语句Oracle数据库中执行sql更新时以随机方式生成的。案件详情如下:

try {
        connection = getConnection();
        statement = connection.prepareStatement(sql);
        for (int i = 0; i < params.length; i++) {
            if (params[i] instanceof Date) {
                statement.setTimestamp(i + 1, new Timestamp(((Date) params[i]).getTime()));
            } else if (params[i] instanceof java.util.Date) {
                statement.setTimestamp(i + 1, new Timestamp(((java.util.Date) params[i]).getTime()));
            } else {
                statement.setObject(i + 1, params[i]);
            }
            paramsBuilder.append(": " + params[i]);
        }
        if (logger.isInfoEnabled()) {
            logger.info("Query String  [" + sql + "] [" + paramsBuilder + "]");
            logger.info("Query Parameters [" + paramsBuilder + "]");
        }
        result = statement.executeUpdate();
        if (logger.isInfoEnabled()) {
            logger.info(result + " rows affected");
        }
    } catch (SQLException e) {
        if (logger.isInfoEnabled()) {
            String message = "Failed to execute SQL statment [" + sql + "] with parameters [" + paramsBuilder + "]";
            logger.error(message, e);
        }
        throw new DAOException(e);
    }

和log中的值是这样的:
Failed to execute SQL statment [update CUSTOMER_CASE set no_of_ptp=?, no_of_unreached=?,collector_name=? , last_case_status_history_id=?, current_handler=?, handling_start_time=?,due_total_open_amount=?, payment_due_invoice_id =?  where id=?] with parameters [: 0: 0: auto: 5470508: null: null: 0.0: 23410984: 2476739] java.sql.SQLException: ORA-01722: invalid number

通过在DB上跟踪查询参数,所有参数均通过JDBC驱动程序正确传输,但参数 23410984 除外,该参数已由值"<C4>^X*U"替换(请注意,此值在char'u'之前包含回车符!)。我不知道为什么

最佳答案

关键原因是关于java.sql.SQLException: ORA-01722: invalid number
可能是last_case_status_history_id字段的类型为number,但您的参数为null

关于java - 我不明白ORA-01722背后的原因: invalid number,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10636114/

10-11 03:32