Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 19354 invoked from network); 26 Jan 2006 19:46:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 26 Jan 2006 19:46:48 -0000 Received: (qmail 84781 invoked by uid 500); 26 Jan 2006 19:46:46 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 84758 invoked by uid 500); 26 Jan 2006 19:46:46 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 84747 invoked by uid 99); 26 Jan 2006 19:46:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 11:46:46 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE,UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [192.18.98.36] (HELO brmea-mail-4.sun.com) (192.18.98.36) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jan 2006 11:46:45 -0800 Received: from fe-amer-04.sun.com ([192.18.108.178]) by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id k0QJkOuf009165 for ; Thu, 26 Jan 2006 12:46:24 -0700 (MST) Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) id <0ITP00501T9I0L00@mail-amer.sun.com> (original mail from Nathan.Maves@Sun.COM) for user-java@ibatis.apache.org; Thu, 26 Jan 2006 12:46:24 -0700 (MST) Received: from [129.147.48.127] by mail-amer.sun.com (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPSA id <0ITP00EVATLBSEW1@mail-amer.sun.com> for user-java@ibatis.apache.org; Thu, 26 Jan 2006 12:46:24 -0700 (MST) Date: Thu, 26 Jan 2006 12:46:44 -0700 From: Nathan Maves Subject: Re: iBatis Subquery and Date error In-reply-to: Sender: Nathan.Maves@Sun.COM To: user-java@ibatis.apache.org Message-id: <06B6DA5C-41CC-4330-9974-25CE4E4E90C6@sun.com> MIME-version: 1.0 X-Mailer: Apple Mail (2.746.2) Content-type: multipart/alternative; boundary="Boundary_(ID_I97294hl73t2Yr23XZKWJQ)" References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --Boundary_(ID_I97294hl73t2Yr23XZKWJQ) Content-type: text/plain; format=flowed; delsp=yes; charset=WINDOWS-1252 Content-transfer-encoding: QUOTED-PRINTABLE Yeah after I sent that I saw that it would not work. What DB are you using? On Jan 26, 2006, at 10:22 AM, Bondre, Prathit wrote: > Hi Nathan, > > Thanks for your response. > > However the #name# and #effDate# do not work in the select =20 > statement and my guess is because in a prepared statement you =20 > cannot specify a ? in the select. > > I have tried this already. > > That=92s why I had to use the $effDate$ instead and use the stateme= nt =20 > and remapResults. It worked for the name but not for the date. > > > > > > > > From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM] > Sent: Thursday, January 26, 2006 11:17 AM > To: user-java@ibatis.apache.org > Subject: Re: iBatis Subquery and Date error > > > > Here are a few things to do that will not solve your problem but = =20 > will help clean it up. > > > > 1. Use the instead of > > 2. Don't specify "remapResults" because you dont have any :) This = =20 > option is not available in an see item #1 > > > > To fix your problem.... > > > > use #name# and #effDate# > > > > you are also missing the id parameter in the HashMap > > > > > > Stick with java.sql.Date. Try never to use java.util.Date. > > > > Nathan > > > > > > > > > > On Jan 26, 2006, at 9:41 AM, Bondre, Prathit wrote: > > > > > I currently have a query defined in my XML as follows > > > > remapResults=3D=94true=94> > > Insert into table > > Select > > Address, > > City, > > Zip, > > $name$ as name, > > $effDate$ as date > > From > > Table > > Where > > Id =3D #id# > > > > > > When I call it using the HashMap and set the effDate with =20 > java.sql.Date object it throws an exception > > That the value is not compatible with the datatype of the target = =20 > which is defined in the database as a Date field. > > Also based on the documentation I also tried to pass in a =20 > java.util.Date instead of the java.sql.Date and it got an error > > =93An unexpected token was found=94 and it seemed like it was passi= ng =20 > in the String version of the Date field which included the =20 > timestamp in the data and it was choking on the : in the timestamp. > > > > How should I be passing the effDate to this query? > > > > So far I had > > HashMap params =3D new HashMap(); > > Params.put(=93name=94,=94Value=94) > > Params.put (=93effDate=94,effDate) // effDate is an instance of = =20 > java.sql.Date . Also tried with java.util.Date. > > > > What am I doing wrong? > > > > Any help will be appreciated. > > > > Thanks, > > Prathit Bondre > > > > > > > > > --Boundary_(ID_I97294hl73t2Yr23XZKWJQ) Content-type: text/html; charset=WINDOWS-1252 Content-transfer-encoding: QUOTED-PRINTABLE Yeah after I sent that I saw = that it would not work.

What DB are you using?


On Jan 26, 2006, at 10:22 AM, Bond= re, Prathit wrote:

Hi Nathan,

Thanks for your response.=

However the #name# a= nd #effDate# do not work in the select statement and my guess is beca= use in a prepared statement you cannot specify a ? in the select.

I have tried this= already.

That= =92s why I had to use the $effDate$ instead and use the statement and= remapResults. It worked for the name but not for the date.

=A0

<= O:P style=3D"color: rgb(0, 0, 128); font-family: Arial; font-size: 13= .3333px; ">=A0

=A0

<= SPAN class=3D"Apple-style-span" style=3D"font-family: Times New Roman= ; font-size: 16px; text-align: center; ">

From: Nathan.Maves@Sun.COM [mailto:Nathan.Maves@Sun.COM]
Sent: Thursday, Jan= uary 26, 2006 11:17 AM
user-java@ibatis.apache.org
Subject:
Re: iBatis Subquery and Date error

=A0

Here are a few things to do that will n= ot solve your problem but will help clean it up.

=A0=

1. Use the <insert&= gt; instead of <statement>

<= P class=3D"MsoNormal">2. Don't specify "remapResults" becaus= e you dont have any :)=A0 This option is not available in an <inse= rt> see item #1

=A0

To fix your problem....

=A0

=

use #name# and #effDate#<= /O:P>

=A0

you are also missing the id parameter in the HashMap

=A0=

=A0=

Stick wi= th java.sql.Date.=A0 Try never to use java.util.Date.

=A0=

Nathan

=A0

=A0

=A0

= =A0

<= FONT size=3D"3" face=3D"Times New Roman">On Jan 26, 2006, at 9:41 AM, Bondre, Prathit wrote:= =



I currently have a query defined in my= XML as follows=

=A0<= /P>

<statement id=3D= =94insertQuery=94 parameterClass=3D=94java.util.Map=94 remapResults= =3D=94true=94>

=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 Insert into table<= FONT color=3D"black">

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Select

=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Address,<= /SPAN>

=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 City,

= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 Zip,<= SPAN style=3D"color:black; font-family: Times New Roman; font-size: 1= 6px; ">

= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 $name$ as name,

=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 $e= ffDate$ as date<= O:P style=3D"font-family: Times New Roman; font-size: 16px; "><= /SPAN>

=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 From

= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 Table= = =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Where

= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 Id =3D #id#

</statement>= =A0

When I call it usi= ng the HashMap and set the effDate with java.sql.Date object it throw= s an exception

That the= =A0 value is not compatible with the datatype of the target which is = defined in the database as a Date field.

Also based on the documentation I also tried to pass i= n a java.util.Date instead of the java.sql.Date and it got an error=

=

=93An unexpected toke= n was found=94 and it seemed like it was passing in the String versio= n of the Date field which included the timestamp in the data and it w= as choking on the : in the timestamp.

= =A0

How s= hould I be passing the effDate to this query?<= FONT color=3D"black">

=A0= S= o far I had

HashMap = params =3D new HashMap();Params.put(=93name=94,=94Value=94)

Params.put (=93effDate=94,effDate) // effDate is an in= stance of java.sql.Date . Also tried with java.util.Date.

=A0

What am I doing wrong?

= =A0

Any h= elp will be appreciated.= =A0

Thanks,

Prathit Bondre<= /SPAN>

= =A0



<= O:P style=3D"font-family: Times New Roman; font-size: 16px; "><= /P>

=A0

=


--Boundary_(ID_I97294hl73t2Yr23XZKWJQ)--