Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 93416 invoked from network); 26 Mar 2005 09:57:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Mar 2005 09:57:44 -0000 Received: (qmail 60610 invoked by uid 500); 26 Mar 2005 09:57:41 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 60562 invoked by uid 500); 26 Mar 2005 09:57:40 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: 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 60547 invoked by uid 99); 26 Mar 2005 09:57:40 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from ajax-1.apache.org (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.28) with ESMTP; Sat, 26 Mar 2005 01:57:38 -0800 Received: by ajax.apache.org (Postfix, from userid 99) id 4FC8828A; Sat, 26 Mar 2005 10:57:34 +0100 (CET) From: bugzilla@apache.org To: commons-dev@jakarta.apache.org Subject: DO NOT REPLY [Bug 34187] New: - [dbcp] allow to register a wrapper extending DelegatingPreparedStatement to enhance setString for compatibility ("schema not null" issue) X-Bugzilla-Reason: AssignedTo Message-Id: <20050326095734.4FC8828A@ajax.apache.org> Date: Sat, 26 Mar 2005 10:57:34 +0100 (CET) X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . 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=34187 Summary: [dbcp] allow to register a wrapper extending DelegatingPreparedStatement to enhance setString for compatibility ("schema not null" issue) Product: Commons Version: unspecified Platform: Other OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Dbcp AssignedTo: commons-dev@jakarta.apache.org ReportedBy: hauser@acm.org It would be great to be able to register a wrapper enhancing org.apache.commons.dbcp.DelegatingPreparedStatement. One purpose of this could be to enhance its setString() method to cope with portability issues between databases and their jdbc drivers: - mysql considers "" as a non-null string - oracle complains that an attempt to insert a null string was made with "". A little test case to illustrate will be appended at the end of this description. So, to create portability, dbcp users have the advantage that their applications don't use the jdbc.jar's setString and getString methods directly anyway. Therefore, the proposed wrapper's setString() method should 1) detect whether ojdbc_14.jar or alike is used 2) if getting "", change this to a never used string such as "eCoUnTeReDsTrInGoFlEnGtHzErO" Similarly, the DelegatingResultSet's getString() would have to be wrapped accordingly, therefore 3) the DelegatingResultSet's wrapper's getString() would do the same in reverse. Anyway, even if either oracle or mysql breaks the standard, it is unlikely to have them quickly converge to the same behaviour, thus such an enhancement could allow programmers to elegantly fix this and gain easy portability not requiring them make their applications/db schemes aware of such idiosyncrasies. ------------- In the below code, the mysql jdbc complains at the third attempt to insert while recent oracle jdbc already refuses to execute variant 2: stmt = this.conn.createStatement( java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_UPDATABLE); stmt.executeUpdate("DROP TABLE IF EXISTS schmNotNull"); stmt .executeUpdate("CREATE TABLE schmNotNull (" + "msg_id INT NOT NULL AUTO_INCREMENT UNIQUE, " + "subject CHAR(255) NOT NULL, PRIMARY KEY (msg_id))"); PreparedStatement insSenderStmt = null; //attempt 1 insSenderStmt = this.conn .prepareStatement("INSERT INTO schmNotNull ( subject) " + " VALUES (?);"); insSenderStmt.setString(1, "testSubj"); // subject log.debug("insSenderStmt: " + ((DelegatingPreparedStatement) insSenderStmt) .getDelegate().toString()); int retVal = insSenderStmt.executeUpdate(); log.debug("retVal1: " + retVal); //attempt 2 insSenderStmt.setString(1, ""); log.debug("insSenderStmt: " + ((DelegatingPreparedStatement) insSenderStmt) .getDelegate().toString()); retVal = insSenderStmt.executeUpdate(); log.debug("retVal2: " + retVal); //attempt 3 insSenderStmt.setString(1, null); log.debug("insSenderStmt: " + ((DelegatingPreparedStatement) insSenderStmt) .getDelegate().toString()); retVal = insSenderStmt.executeUpdate(); log.debug("retVal3: " + retVal); so, the output of mysql looks like: <> -- 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