Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 48856 invoked from network); 2 Nov 2006 07:26:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Nov 2006 07:26:41 -0000 Received: (qmail 35155 invoked by uid 500); 2 Nov 2006 07:26:50 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 35083 invoked by uid 500); 2 Nov 2006 07:26:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 35071 invoked by uid 99); 2 Nov 2006 07:26:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Nov 2006 23:26:50 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Nov 2006 23:26:38 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id D47567142BF for ; Wed, 1 Nov 2006 23:26:17 -0800 (PST) Message-ID: <29219443.1162452377867.JavaMail.root@brutus> Date: Wed, 1 Nov 2006 23:26:17 -0800 (PST) From: "Henri Yandell (JIRA)" To: commons-dev@jakarta.apache.org Subject: [jira] Commented: (DBUTILS-27) [dbutils] QueryRunner.count(String, ...) methods for SELECT COUNT(...) sql MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/DBUTILS-27?page=comments#action_12446473 ] Henri Yandell commented on DBUTILS-27: -------------------------------------- In comparison to DBUTILS-17, the method name is more focused here (count(..)), but the method doesn't take care of the "select count(*)", so you could quite happily pass something in that is not a count method. This makes it just a weakly described version of DBUTILS-17. It does handle the null to 0 semantics that make sense in the case of a count request, and it is returning an int rather than the Integer/Long that DBUTILS-17 has to do because it uses the Handler system. The API could be changed to only have the where clause, but that seems pretty weak. Maybe this should be a: public long QueryRunner.queryForLong(...) > [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.1 > > 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