我正在为 Informix 使用 JDBC 驱动程序。我很好地连接到我的主机,但是当执行查询时,我的选择中指定的字段之一返回空值。而不是仅仅检索该值,并且 SQLException 被抛出:
在查询的任何表中都找不到列 (colname)(或 SLV 未定义)。
我以这种方式使用驱动程序:
try{
PreparedStatement pstmtDist = conn.prepareStatement(query2);
ResultSet rsDist = pstmtDist.executeQuery();
while(rsDist.next()){
int distCaseId = 0;
String distCaseIdStr = new String();
int distCaseDefNum = 0;
String distCaseDefNumStr = new String();
distCaseIdStr = rsDist.getObject("colname").toString();
distCaseId = Integer.parseInt(distCaseIdStr.trim());
distCaseDefNumStr = rsDist.getObject("colname2").toString();
distCaseDefNum = Integer.parseInt(distCaseDefNumStr.trim());
//System.out.println(String.format("distCaseId == %d distCaseDefNum == %d\n",distCaseId,distCaseDefNum));
}// end while district cases
rsDist.close();
pstmtDist.close();
connDist.close();
}
catch (SQLException e){
System.out.println("EXCEPTION: "+e.getMessage());
}
欢迎任何提示!
-TU