如果查询没有返回任何记录,结果集的值是多少?

van*_*ita -1 java

public ResultObject takePrefixGroupId(ArrayList prefixGroupName) 
{
 debugLog(MODULE_NAME, "Inside the takePrefixGroupId() of LCRConfigurationSessionBean");
 ResultObject resultObject = new ResultObject(LCRResponseCode.LCR_CONFIGURE_SEARCH_ERROR_EJB, null);

 String strSelectQuery = null;
 String strMessage=null;
 ResultSet resSet = null;
 Collection colInValideRecord =new ArrayList();
 Collection colErrorMessage=new ArrayList();
 Collection colValidRecord = new ArrayList();
 Collection colDataValidation=null;
 try{
  for(int i=0;i<prefixGroupName.size();i++)
  {
   strSelectQuery = "select DESTINATIONGROUPID from TBLMDESTINATIONGROUP where NAME='"+prefixGroupName.get(i)+"'";
   debugLog(MODULE_NAME, "Query::::::"+strSelectQuery);   
   resultObject = execute(strSelectQuery);
   if(resultObject.getResponseCode() == LCRResponseCode.SUCCESS_RESPONSE_CODE)
   {
    resSet = (ResultSet)resultObject.getResponseObject();
    debugLog(MODULE_NAME, "resSet::::::"+resSet);
    if(resSet != null)
    {
     while(resSet.next())
     {
      colValidRecord.add(resSet.getString("DESTINATIONGROUPID"));
     }
    }
    else
    {
     strMessage=LCRResponseCode.errorCodeToMessage(LCRResponseCode.PREFIX_GROUP_DOES_NOT_EXIST_ERROR);
     debugLog(MODULE_NAME,"MESSAGE::: "+strMessage);
     colErrorMessage.add(strMessage);
     colInValideRecord.add(prefixGroupName);
     debugLog(MODULE_NAME,"No Prefix Group is found."); 
    }
    colDataValidation=new ArrayList();
    colDataValidation.add(colValidRecord);
    colDataValidation.add(colInValideRecord);
    colDataValidation.add(colErrorMessage);
    resultObject.setResponseObject(colDataValidation);      
    resultObject.setResponseCode(LCRResponseCode.SUCCESS_RESPONSE_CODE);

   }
   else
   {
    debugLog(MODULE_NAME, "Unable to execute search query for in searchDestination() of LCRConfigurationSessionBean.");
    resultObject.setResponseCode(LCRResponseCode.LCR_CONFIGURE_SEARCH_ERROR_EJB);
   }
  }

 }
 catch(Exception e)
 {
  e.printStackTrace();
  errorLog(MODULE_NAME, "exception in searchDestination() of LCRConfigurationSessionBean");
  resultObject.setResponseCode(LCRResponseCode.LCR_CONFIGURE_SEARCH_ERROR_EJB);
  resultObject.setException(e);
 }  
 return resultObject;
}
Run Code Online (Sandbox Code Playgroud)

这是代码

Ste*_*n C 6

根据javadoc,Statement.executeQuery()永远不会回来null.所以答案是ResultSet没有行.

你可以告诉大家的ResultSet是空的,如果next()回到false你第一次调用它.

您也可以通过调用可选 isAfterLast()方法来判断.如果支持,此方法将为您提供答案,而不会将光标作为副作用提前.


我不知道你的代码的答案是什么,因为你正在调用一个execute你没有提供的实现方法.