[dbUtils] - QueryRunner question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[dbUtils] - QueryRunner question

Jonathan E Bricker
I'm getting an SQLException with
QueryRunner.update(Connection,String,Object[]) method and I wanted to see
if I was doing this correctly.

My values for the insert come from a ValueObject.  All of the fields are
Strings EXCEPT informed_consent_date which is a date and Patient_Id which
is a BigDecimal.  Patient_ID is null because there is a trigger that will
fill that field.

I take my fields in the VO and put them in an ArrayList then use
toArray(Object[]) to get them into the array.

When I use the method I get an InvalidColumn.  I suspect that this is the
Date fields not matching or getting translated correctly.  Any ideas would
be helpful.

SQLException = Invalid column type Query: insert into ATD_PATIENT
(PATIENT_ID,GENDER_CODE,BIRTH_YEAR,INFORMED_CONSENT_DATE,ENCRYPTED_EXTERNAL_ID,RACIAL_GROUP,SPECIES,COLLABORATION,USER_1_USER_ID)
VALUES(?,?,?,?,?,?,?,?,?) Parameters: [null, M, 1965, 2005-05-05,
auDcPckKiXAkFpzwGHqFYaqPdgI, White, Human, IU, 11]


Jonathan Bricker
Lilly Research Labs

Reply | Threaded
Open this post in threaded view
|

Antwort: [dbUtils] - QueryRunner question [Virus checked]

Ulrich.Kleeberger
hi,

i had a similar problem with a oracle database. the trick was to use a
timestamp object instead of a date object.

for example :

Date a = new Date();
new Timestamp( a.getTime() );

hope this helps.

uli







Jonathan E Bricker <[hidden email]>
12.05.05 16:29
Bitte antworten an
"Jakarta Commons Users List" <[hidden email]>


An
[hidden email]
Kopie

Thema
[dbUtils] - QueryRunner question [Virus checked]






I'm getting an SQLException with
QueryRunner.update(Connection,String,Object[]) method and I wanted to see
if I was doing this correctly.

My values for the insert come from a ValueObject.  All of the fields are
Strings EXCEPT informed_consent_date which is a date and Patient_Id which
is a BigDecimal.  Patient_ID is null because there is a trigger that will
fill that field.

I take my fields in the VO and put them in an ArrayList then use
toArray(Object[]) to get them into the array.

When I use the method I get an InvalidColumn.  I suspect that this is the
Date fields not matching or getting translated correctly.  Any ideas would

be helpful.

SQLException = Invalid column type Query: insert into ATD_PATIENT
(PATIENT_ID,GENDER_CODE,BIRTH_YEAR,INFORMED_CONSENT_DATE,ENCRYPTED_EXTERNAL_ID,RACIAL_GROUP,SPECIES,COLLABORATION,USER_1_USER_ID)

VALUES(?,?,?,?,?,?,?,?,?) Parameters: [null, M, 1965, 2005-05-05,
auDcPckKiXAkFpzwGHqFYaqPdgI, White, Human, IU, 11]


Jonathan Bricker
Lilly Research Labs




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [dbUtils] - QueryRunner question

David Graham
In reply to this post by Jonathan E Bricker
Make sure you are using a java.sql.Date and not a java.util.Date.  Some
JDBC drivers accept java.util.Date but others only accept java.sql.Date or
java.sql.Timestamp.  If I remember correctly, the JDBC spec only requires
drivers to accept java.sql.Date in PreparedStatement.setObject().

David

--- Jonathan E Bricker <[hidden email]> wrote:

> I'm getting an SQLException with
> QueryRunner.update(Connection,String,Object[]) method and I wanted to
> see
> if I was doing this correctly.
>
> My values for the insert come from a ValueObject.  All of the fields are
>
> Strings EXCEPT informed_consent_date which is a date and Patient_Id
> which
> is a BigDecimal.  Patient_ID is null because there is a trigger that
> will
> fill that field.
>
> I take my fields in the VO and put them in an ArrayList then use
> toArray(Object[]) to get them into the array.
>
> When I use the method I get an InvalidColumn.  I suspect that this is
> the
> Date fields not matching or getting translated correctly.  Any ideas
> would
> be helpful.
>
> SQLException = Invalid column type Query: insert into ATD_PATIENT
>
(PATIENT_ID,GENDER_CODE,BIRTH_YEAR,INFORMED_CONSENT_DATE,ENCRYPTED_EXTERNAL_ID,RACIAL_GROUP,SPECIES,COLLABORATION,USER_1_USER_ID)
>
> VALUES(?,?,?,?,?,?,?,?,?) Parameters: [null, M, 1965, 2005-05-05,
> auDcPckKiXAkFpzwGHqFYaqPdgI, White, Human, IU, 11]
>
>
> Jonathan Bricker
> Lilly Research Labs
>
>

Get Firefox!
http://www.mozilla.org/firefox/


               
__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]