You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/09/27 00:43:02 UTC

DO NOT REPLY [Bug 36822] New: - [dbutils] QueryRunner.count(String, ...) methods for SELECT COUNT(...) sql

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36822>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36822

           Summary: [dbutils]  QueryRunner.count(String, ...) methods for
                    SELECT COUNT(...) sql
           Product: Commons
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: DbUtils
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: heuermh@acm.org


Found that I was repeating the same bit of code over and over again when executing SELECT COUNT(...) 
sql queries with QueryRunner, so I thought I might code this up into a set of static methods for possible 
inclusion in commons-dbutils.

e.g.

Connection conn;
String sql = "select count(*) from tablename where column0 = ? and column1 = ?";

from:

int count = 0;
Object result = QueryRunner.query(conn, sql, new Object[] { "foo", "bar" }, new ScalarHandler());
if (result != null) {
  count = ((Integer) result).intValue();
}

to:

int count = QueryRunner.count(conn, sql, new Object[] { "foo", "bar" });

See attached diff.txt.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org