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: [email protected]
        ReportedBy: [EMAIL PROTECTED]


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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to