Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 63744 invoked from network); 22 Mar 2005 16:34:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 Mar 2005 16:34:49 -0000 Received: (qmail 63952 invoked by uid 500); 22 Mar 2005 16:34:48 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 63911 invoked by uid 500); 22 Mar 2005 16:34:48 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 63895 invoked by uid 99); 22 Mar 2005 16:34:48 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from brmea-mail-4.Sun.COM (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 22 Mar 2005 08:34:46 -0800 Received: from phys-biff-1 ([129.158.227.36]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id j2MGYfXC018141 for ; Tue, 22 Mar 2005 09:34:44 -0700 (MST) Received: from conversion-daemon.biff-mail1.india.sun.com by biff-mail1.india.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) id <0IDR00201HX7HT@biff-mail1.india.sun.com> (original mail from Shreyas.Kaushik@Sun.COM) for derby-dev@db.apache.org; Tue, 22 Mar 2005 22:04:41 +0530 (IST) Received: from [192.168.1.100] (vpn-129-150-156-18.India.Sun.COM [129.150.156.18]) by biff-mail1.india.sun.com (iPlanet Messaging Server 5.2 HotFix 1.24 (built Dec 19 2003)) with ESMTP id <0IDR00270I1RFF@biff-mail1.india.sun.com> for derby-dev@db.apache.org; Tue, 22 Mar 2005 22:04:40 +0530 (IST) Date: Tue, 22 Mar 2005 22:05:32 +0530 From: Shreyas Kaushik Subject: Re: [PATCH] Derby-174 In-reply-to: To: Derby Development Message-id: <42404954.9060003@sun.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) References: <423FD14D.6020607@Sun.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Mamta, Thanks for your comments. Currently the *setInto* method is not overridden in SQLTimestamp.java, hence it uses the one defined in DataType.java which is as shown below, public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException { ps.setObject(position, getObject()); } Here there is a call to getObject() which is overridden in SQLTimestamp.java which calls getTimestamp((Calendar)null); which returns null. Since the setObject cannot take an utyped null ( according to JDBC 3.0 spec ) it throws an Exception. So calling setInto in this case is equivalent to calling ps.setTimestamp(position, getTimestamp((Calendar) null)); So whenever setInto is called on a Timestamp it is as if I am calling the above code. ~ Shreyas Mamta Satoor wrote: >On Tue, 22 Mar 2005 13:33:25 +0530, Shreyas Kaushik > wrote: > > >>Find the patch for this attached. I will send the test patch in a >>seperate mail. >> >>~ Shreyas >> >> >>Index: java/engine/org/apache/derby/iapi/types/SQLTimestamp.java >>=================================================================== >>--- java/engine/org/apache/derby/iapi/types/SQLTimestamp.java (revision 158017) >>+++ java/engine/org/apache/derby/iapi/types/SQLTimestamp.java (working copy) >>@@ -45,12 +45,7 @@ >>import org.apache.derby.iapi.types.SQLDouble; >>import org.apache.derby.iapi.types.SQLTime; >> >>-import java.sql.Date; >>-import java.sql.Time; >>-import java.sql.Timestamp; >>-import java.sql.Types; >>-import java.sql.ResultSet; >>-import java.sql.SQLException; >>+import java.sql.*; >> >>import java.util.Calendar; >>import java.util.GregorianCalendar; >>@@ -989,5 +984,10 @@ >> currentCal.setTime(value); >> return SQLTime.computeEncodedTime(currentCal); >> } >>+ >>+ public void setInto(PreparedStatement ps, int position) throws SQLException, StandardException { >>+ >>+ ps.setTimestamp(position, getTimestamp((Calendar) null)); >>+ } >>} >> >> >> >> >> > >Hi Shreyas, > >Haven't looked into details of current implementation of setInto >methods by other datatypes, but I did notice that most other datatypes >have coded setInto method as follows >//this method is from SQLDecimal.java >public final void setInto(PreparedStatement ps, int position) throws >SQLException { > if (isNull()) { > ps.setNull(position, java.sql.Types.DECIMAL); > return; > } > ps.setBigDecimal(position, getBigDecimal()); >} > >Seems like they first check for isNULL and call different methods >depending on whether the method is dealing with null or not. Wondered >why your patch does not check for null before calling ps.setTimestamp >method? > >Mamta > >