This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have following codesegment. preparedStat = dbConnection.prepareStatement(sqlQuery); int index = 1; for (Object sqlParam : sqlParams) { if (sqlParam instanceof String) { preparedStat.setString(index, (String) sqlParam); } else if (sqlParam instanceof Date) { preparedStat.setTimestamp(index, new Timestamp(((Date)sqlParam).getTime())); } else if (sqlParam instanceof Timestamp) { preparedStat.setTimestamp(index, (Timestamp)sqlParam); } else if (sqlParam instanceof BigDecimal) { preparedStat.setBigDecimal(index, (BigDecimal)sqlParam); } else if (sqlParam instanceof Boolean) { preparedStat.setBoolean(index, (Boolean)sqlParam); } else if (sqlParam instanceof Double) { preparedStat.setDouble(index, (Double)sqlParam); } else if (sqlParam instanceof Float) { preparedStat.setFloat(index, (Float)sqlParam); } else if (sqlParam instanceof Integer) { preparedStat.setInt(index, (Integer)sqlParam); } else if (sqlParam instanceof Long) { preparedStat.setLong(index, (Long)sqlParam); } else if (sqlParam == null) { preparedStat.setNull(index, Types.NULL); } index++; } I wanted to extract the inner part of the for loop and following was extracted: ... preparedStat = dbConnection.prepareStatement(sqlQuery); int index = 1; for (Object sqlParam : sqlParams) { setDbParam(preparedStat, index); index++; } ... private void setDbParam(PreparedStatement preparedStat, int index) throws SQLException { Object sqlParam; if (sqlParam instanceof String) { preparedStat.setString(index, (String) sqlParam); } else if (sqlParam instanceof Date) { preparedStat.setTimestamp(index, new Timestamp(((Date)sqlParam).getTime())); } else if (sqlParam instanceof Timestamp) { preparedStat.setTimestamp(index, (Timestamp)sqlParam); } else if (sqlParam instanceof BigDecimal) { preparedStat.setBigDecimal(index, (BigDecimal)sqlParam); } else if (sqlParam instanceof Boolean) { preparedStat.setBoolean(index, (Boolean)sqlParam); } else if (sqlParam instanceof Double) { preparedStat.setDouble(index, (Double)sqlParam); } else if (sqlParam instanceof Float) { preparedStat.setFloat(index, (Float)sqlParam); } else if (sqlParam instanceof Integer) { preparedStat.setInt(index, (Integer)sqlParam); } else if (sqlParam instanceof Long) { preparedStat.setLong(index, (Long)sqlParam); } else if (sqlParam == null) { preparedStat.setNull(index, Types.NULL); } } Obviously the ide did NOT detect sqlParam as a parameter for the setDbParam method, which it should have. Product Version: NetBeans IDE Dev (Build 201106041000) Java: 1.6.0_25; Java HotSpot(TM) 64-Bit Server VM 20.0-b11 System: Windows 7 version 6.1 running on amd64; Cp1252; de_AT (nb) Userdir: C:\Users\thomas.zillinger\.netbeans\dev
Thanks for the testcase. Fixed in trunk by: http://hg.netbeans.org/jet-main/rev/e50868ad7957 and in release701 by: http://hg.netbeans.org/releases/rev/09f8a756d359
Integrated into 'releases' Changeset: http://hg.netbeans.org/releases/rev/09f8a756d359 User: Jan Lahoda <jlahoda@netbeans.org> Log: #199335: need to scan the enhanced for loop variable too.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/e50868ad7957 User: Jan Lahoda <jlahoda@netbeans.org> Log: #199335: need to scan the enhanced for loop variable too.