简体   繁体   中英

Not able to execute the query in java

I'm executing the query,

SELECT  
  UNIQUE PXCID,SNCID,FREQUENCY 
FROM 
  AFFECTEDXCS 
WHERE 
  PTPNAME IN ('AM2125A-1-14-LINEIN','AM2125A-1-15-LINEOUT','CWR-7-14-CLS2') 
AND FREQUENCY='9170' and NENAME='CP0MP1-121-N2-SITE3' 
ORDER BY SNCID;

from SQL Developer, it gives me row of value?

Same query i'm trying to execute it from java with the code.

String query =  DBStatements.PXCID_LIST;
        Object[] param = new Object[3];
        param[0]="AM2125A-1-14-LINEIN,AM2125A-1-15-LINEOUT,CWR-7-14-CLS2";
        param[1]=frequency;
        param[2]=nodelabel;
List<Map<String,Object>> returnList = eqmqueryexec.executeQuery(EQMDataSource.OTN, "0", query, param);
        Iterator<Map<String,Object>> iter = returnList.iterator();
        logger.debug("iterator bolean length"+iter.hasNext());

I'm getting the "iterator bolean length" as false. That's means the query as not executed properly?

Every params you need to bind withing IN clause should be individual question marks rather than only one que. mark for whole IN clause.. like

SELECT * FROM employees WHERE emp_id IN(?,?,?,?,?)

and you have to bind variable for each param separately..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM