准备好的语句不起作用,resultset.next()没有记录

时间:2017-04-07 07:18:31

标签: java oracle

在java代码下运行

final String Qry = QueryConstants.QUERY;
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            con = getDataSource().getConnection();
            stmt = con.prepareStatement(Qry);
            stmt.setString(1, abc1);
            stmt.setLong(2, abc2);          
            stmt.setString(3, abc3);
            long st = System.currentTimeMillis();
                rs = stmt.executeQuery();
            long end = System.currentTimeMillis();
            logger.error("RetrialDaoImpl.fetchFailedMessageFromDb:: time taken to fetch failed messages::" + (end - st) + "|likePattern::" + likePattern);
            while (rs.next()) {
                System.out.println(rs.getString("VERSION_NUMBER"));
            }

QUERY在下面

SELECT MAX(VERSION_NUMBER) AS VERSION_NUMBER,  TLO_TYPE, TLO_ID 
FROM MSG_XML WHERE STATUS ='N' AND RECOVERABLE_FLAG ='Y' and PATTERN  =1 AND  ROWNUM <= 100 GROUP BY TLO_TYPE, TLO_ID) t1, MSG_XML x 
WHERE x.TLO_TYPE = t1.TLO_TYPE AND NVL(x.TLO_ID,1) = NVL(t1.TLO_ID,1) AND x.vdps_version_number = t1.vdps_version_number AND x.status  ='N' AND X.RECOVERABLE_FLAG ='Y' AND x.PATTERN = 1 ORDER BY X.RETRY_COUNT,  X.UPDATED_TIME

MSG_XML是一个视图。尝试在sql开发人员上运行sql,它返回一条记录,然后为什么结果集不会返回任何内容。

0 个答案:

没有答案