[hg] main-silver: #231030: Fix SQLExecutionHelper.getTotalCount

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #231030: Fix SQLExecutionHelper.getTotalCount
  • Date: Fri, 21 Jun 2013 04:47:17 -0700

changeset 5ad93a1b4bde in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/5ad93a1b4bde
description:
        #231030: Fix SQLExecutionHelper.getTotalCount

diffstat:

 
db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java
 |  47 +---------
 1 files changed, 2 insertions(+), 45 deletions(-)

diffs (83 lines):

diff --git 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java
 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java
--- 
a/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java
+++ 
b/db.dataview/src/org/netbeans/modules/db/dataview/output/SQLExecutionHelper.java
@@ -913,18 +913,6 @@
             return;
         }
 
-        // Case for LIMIT n OFFSET m
-        if (isLimitUsedInSelect(sql)) {
-            try {
-                String lmtStr = 
sql.toUpperCase().split(LIMIT_CLAUSE)[1].trim();
-                int rCnt = Integer.parseInt(lmtStr.split(" ")[0]);
-                pageContext.setTotalRows(rCnt);
-                return;
-            } catch (NumberFormatException nex) {
-                LOGGER.log(Level.FINE, null, nex);
-            }
-        }
-
         // SELECT COUNT(*) FROM (sqlquery) alias
         ResultSet cntResultSet = null;
         try {
@@ -933,6 +921,7 @@
             setTotalCount(cntResultSet, pageContext);
             return;
         } catch (SQLException e) {
+            LOGGER.log(Level.FINE, null, e);
         } finally {
             DataViewUtils.closeResources(cntResultSet);
         }
@@ -946,43 +935,12 @@
                 setTotalCount(cntResultSet, pageContext);
                 return;
             } catch (SQLException e) {
+                LOGGER.log(Level.FINE, null, e);
             } finally {
                 DataViewUtils.closeResources(cntResultSet);
             }
         }
 
-        // In worse case, get the count from resultset
-        cntResultSet = null;
-        int totalRows = 0;
-        try {
-            // reset fetch size
-            int fetchSize = pageContext.getPageSize();
-            try {
-                fetchSize = stmt.getFetchSize();
-                stmt.setFetchSize(20000);
-            } catch (SQLException sqe) {
-                // ignore
-            }
-
-            cntResultSet = stmt.executeQuery(sql);
-            while (cntResultSet.next()) {
-                totalRows++;
-            }
-            pageContext.setTotalRows(totalRows);
-
-            // set to old value
-            try {
-                stmt.setFetchSize(fetchSize);
-            } catch (SQLException sqe) {
-                // ignore
-            }
-            return;
-        } catch (SQLException e) {
-            LOGGER.log(Level.FINE, null, e);
-        } finally {
-            DataViewUtils.closeResources(cntResultSet);
-        }
-
         // Unable to compute the total rows
         setTotalCount(null, pageContext);
     }
@@ -1009,7 +967,6 @@
                 if (countresultSet.next()) {
                     int count = countresultSet.getInt(1);
                     pageContext.setTotalRows(count);
-                    pageContext.setTotalRows(count);
                 }
             }
         } catch (SQLException ex) {

[hg] main-silver: #231030: Fix SQLExecutionHelper.getTotalCount

Jaroslav Havlin 06/21/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close