'How to Abort long running query in weblogic struct java application

I have a query some times I get timeout exception and query runs on the backend for ever not displaying any information and causes application to hang up how can I abort the session if the there is no response from the oracle server

public List getRCIDInfoListByRCID(String rcID) throws TimeoutException, ValidationException {
        List dvoList = new ArrayList();
        StrictDAO dao = null;
        try {
            for (Iterator it = RCIDInfoDVO.getCached().entrySet().iterator(); it.hasNext();){
                Map.Entry entry= (Entry) it.next();
                RCIDInfoDVO e = (RCIDInfoDVO) entry.getValue();
                if (e.getRCID().startsWith(rcID)){
                    dvoList.add(e);
                }
            }
            
            dao = DAOFactoryRegistry.getDAOFactory().create(DAOLookupConstant.DAO_GET_RCID_LIST_BY_ID);
            dao.setParamValue("rcid", rcID);
            RowSet rowSet = (RowSet)dao.executeQuery();
            if (rowSet != null) {
                List tmpList = rowSet.getData();      
                if (tmpList != null) {
                    for (Iterator it = tmpList.iterator(); it.hasNext();) {
                        Object[] row = (Object[])(Object)it.next();
                        if (row!=null) {
                          RCIDInfoDVO dvo = new RCIDInfoDVO((String)row[0], (String)row[1], (String)row[2]);
                          dvoList.add(dvo);  
                          RCIDInfoDVO.addToCached(row);//update cache
                        }           
                    }
                }
            }
        } catch (Exception e) {
            logger.error("[Exception] getRCIDInfoListByRCID. Exception:"+ e);
            throw new SystemException(e);
        } finally {
            if (dao != null) {
                dao.release();
                dao = null;
            }
        }
        
        logger.info("getRCIDInfoListByRCID returning :" + dvoList.size()+ "records");       
        return dvoList;
    }

And query is a join between multiple tables I don't want to make any changes to the query as it happens randomly

RowSet rowSet = (RowSet)dao.executeQuery();

How to terminate the query if above code is not responding in 60 seconds?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source