commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Heuer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DBUTILS-27) [dbutils] QueryRunner.count(String, ...) methods for SELECT COUNT(...) sql
Date Sat, 04 Nov 2006 05:29:17 GMT
    [ http://issues.apache.org/jira/browse/DBUTILS-27?page=comments#action_12447121 ] 
            
Michael Heuer commented on DBUTILS-27:
--------------------------------------

Feel free to mark this as WONTFIX.  With the 1.1 release, the method QueryRunner.prepareConnection()
is protected, so I can just include a subclass of QueryRunner in my own code. 

> [dbutils]  QueryRunner.count(String, ...) methods for SELECT COUNT(...) sql
> ---------------------------------------------------------------------------
>
>                 Key: DBUTILS-27
>                 URL: http://issues.apache.org/jira/browse/DBUTILS-27
>             Project: Commons DbUtils
>          Issue Type: Improvement
>         Environment: Operating System: All
> Platform: All
>            Reporter: Michael Heuer
>            Priority: Minor
>             Fix For: 1.2
>
>         Attachments: count.java, count.java, diff.txt
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


Mime
View raw message