Checkmarx scan is giving below bug ""So and so class performs an operation that could be expected to throw an exception and is not properly wrapped with try-catch block.This constitutes improper exceptional handling"
Below is the code snippet
public List getDataforTable(String query,List\<String\> preparedStatementParameterList){
Query queryObj = devEntityManager.createNativeQuery (query, Tuple.class);
for (String dbParameter:preparedStatementParameterList){
if(dbParameter != null && dbParameter.contains("-")) {
String\[\] filterParameter= dbParameter.split("\\\\\\\~\\\\|");
if(filterParameter.length = 2)
queryObj.setParameter(filterParameter \[0\], filterParameter\[1\]);
else queryObj.setParameter (filterParameter\[0\]), "");
}
}
@SuppressWarnings("unchecked") List\<Tuple\> queryRows = queryObj.getResultList();
final List\<Map\<String, Object\>\> formattedRows = new ArrayList\<\>();
utility.resultExtraction (queryRows, formattedRows);
return formattedRows;
}
Checkmarx scan highlighted below line of code and expecting exception handling for the same
queryRows = queryObj.getResultList();
I tried with try-catch block but its not working