title: Checking for a null int value from a Java ResultSet
body: <p>In Java I'm trying to test for a null value, from a ResultSet, where the column is being cast to a primitive <em>int</em> type. </p>
  
  <pre><code>int iVal;
  ResultSet rs = magicallyAppearingStmt.executeQuery(query);
  if (rs.next()) {
    if (rs.getObject("ID_PARENT") != null &amp;&amp; !rs.wasNull()) {
      iVal = rs.getInt("ID_PARENT");
    }
  }
  </code></pre>
  
  <p>From the code fragment above, is there a better way to do this, and I assume that the second <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSet.html#wasNull()" rel="noreferrer">wasNull()</a> test is redundant?</p>
  
  <p>Educate us, and Thanks </p>