尝试使用资源类变量获取无效


        protected void saveData() {
        Map<String, String> allStationsParams = new HashMap<>();
        List<String> stations = getAllStations();
        stmt = Database.getUpdateableStatement();
        today = (SysTime.currentTimeMillis() / DasStamp.TICKS_PER_DAY) * 
        DasStamp.TICKS_PER_DAY;
        String changeTimestamp = DasStamp.asCompactString(today);
        String keyName = "COM.MAPPINGTOOLTIP." + attributeValue;
        for (int row = 0; row < this.getTableModel().getRowCount(); row++) {
            String station = (String)this.getTableModel().getValueAt(row, 0);
            putInStationParams(this, station, allStationsParams, row);
        }
        for (String station : stations) {
            boolean sendToDB = false;
            try (ResultSet rs = this.rsParameters) {
                rs.beforeFirst();
                while (rs.next()) {
                    if (rs.getString("station").equals(station)) {
                        sendToDB = true;
                        break;
                    }
                }
                if (sendToDB) {
                    if (!rs.getString("value_text").equals(allStationsParams.get(station)) || !allStationsParams.containsKey(station)) {
                        sendToDB = true;
                    } else {
                        sendToDB = false;
                    }
                } else if (allStationsParams.containsKey(station)) {
                    sendToDB = true;
                }
                if (sendToDB) {
                    String  sql = "REPLACE INTO dss_parameter (key_name, station, valid_from, value_text"
                            + ", change_timestamp) VALUES ('"
                            + keyName + "','" + station + "','" + DasStamp.asDateOnlyString(today) + "','"
                            + Helper.nz(allStationsParams.get(station)) + "','"
                            + changeTimestamp + "') ;";
                    if (null != stmt) {
                        stmt.execute(sql);
                        if (!isResultSetEmpty(rs) && !rs.isAfterLast()) {
                            AdminLogger.log("dss_parameter", Action.UPDATE,
                                    "key_name='" + keyName + "' and station='" + station + "' and valid_from='" + DasStamp.asDateOnlyString(today) + "'",
                                    "value_text='" + rs.getString("value_text") + "'",
                                    "value_text='" + Helper.nz(allStationsParams.get(station)) + "', change_timestamp='" + changeTimestamp + "'");
                        } else {
                            AdminLogger.log("dss_parameter", Action.INSERT,
                                    "key_name='" + keyName + "' and station='" + station + "' and valid_from='" + DasStamp.asDateOnlyString(today) + "'",
                                    "", "value_text='" + Helper.nz(allStationsParams.get(station)) + "', change_timestamp='" + changeTimestamp + "'");
                        }
                    }
                }
            } catch (SQLException e) {
                AppFrame.msgBox("Error on insert: " + e.getMessage());
                Helper.printMessage(true, false, "Parameter save failed!!", e);
            }
        }
    }

其中rsparameters是班级级别,并且在以前被提取。第一次 迭代,rsparameters值正在恢复为null。 使用资源块?请帮助

其中rsparameters是班级级别,并且在以前被提取。第一次 迭代,rsparameters值正在恢复为null。 使用资源块?请帮助

您的rsparameters参数是类型结果集。在第一次迭代中,尝试{}块是完整的关闭((rsparameters的方法:resultset称为。

这在内部使Resultset null的所有属性。

这是在第二次迭代期间获得无效属性的原因。

%29

相关内容

  • 没有找到相关文章

最新更新