我有一些將查詢結果集放入2維數組的代碼。但是,當數組遇到結果集中的空值時,它會出錯。我該如何解決?遇到空值時出現Java結果集錯誤
query = "SELECT * FROM E_CMS WHERE BOXADDR_AREA IS NULL ORDER BY CBOXID ASC ";
rs = stmt.executeQuery(query);
//insert the table into the 2 dimensional array
while (rs.next()) {
e_cms_Array[count][0] = rs.getString("CBOXID");
e_cms_Array[count][1] = rs.getString("CBOXADD").replace("'","");
e_cms_Array[count][2] = rs.getString("MFLPU");
e_cms_Array[count][3] = rs.getString("SATLPU");
e_cms_Array[count][4] = rs.getString("BOXTYPE");
e_cms_Array[count][5] = rs.getString("SVCCLASS");
e_cms_Array[count][6] = rs.getString("LOCATION_TYPE").replace("'","");
e_cms_Array[count][7] = rs.getString("CHANGE_DATE");
e_cms_Array[count][8] = rs.getString("DEL_FLAG");
e_cms_Array[count][9] = rs.getString("DECAL_PRINT_DT");
e_cms_Array[count][10] = rs.getString("BOXADDR_AREA").replace("'","");
e_cms_Array[count][11] = rs.getString("LASTMF_AREA_O");
e_cms_Array[count][12] = rs.getString("LASTSAT_AREA_O");
System.out.println(count + " :: " +
e_cms_Array[count][0]+"|"+
e_cms_Array[count][1]+"|"+
e_cms_Array[count][2]+"|"+
e_cms_Array[count][3]+"|"+
e_cms_Array[count][4]+"|"+
e_cms_Array[count][5]+"|"+
e_cms_Array[count][6]+"|"+
e_cms_Array[count][7]+"|"+
e_cms_Array[count][8]+"|"+
e_cms_Array[count][9]+"|"+
e_cms_Array[count][10]+"|"+
e_cms_Array[count][11]+"|"+
e_cms_Array[count][12]);
count++;
}
什麼是錯誤信息和堆棧跟蹤? –
@JB Nizet'顯示java.lang.NullPointerException \t在forecast_transmission.get_e_cms(forecast_transmission.java:106) \t在forecast_transmission.main(forecast_transmission.java:44)' – Mike
請提供的完整代碼或SSCCE。向數組中添加空值會導致錯誤是不可能的。 – Heisenbug