Expand my Community achievements bar.

Insert date into database by using JDBC Service/Execute SQL statement in workbench

Avatar

Former Community Member

Hello,

Can any one please advise on the formatting the date so it can be inserted into the database without getting error.

insert into tableA(fieldA, fieldB, dateC)

values (?, ?, ?)

or

insert into tableA(fieldA, fieldB, dateC)

values ('?', '?', '?')

I tried either insert statements above for SQL server but keep getting the below error:

[4/22/13 13:39:43:444 CDT] 0000002e ExceptionUtil E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "doBMT" on bean "BeanId(LiveCycle8#adobe-dscf.jar#EjbTransactionBMTAdapter, null)". Exception data: java.lang.RuntimeException: Conversion failed when converting date and/or time from character string.

But if I manually place the value like the below then it works fine.

insert into tableA(fieldA, fieldB, dateC)

values ('test', 'description', '4/22/2013')

Thanks,

HD

5 Replies

Avatar

Employee Advisor

I am able to do this at my end as below. I am using MYSQL.

JDBC.jpg

Thanks,

Wasil

Avatar

Level 1

this is when you insert with a Test value, if you insert with an actual value from XML what happens ? I keep getting incorrect format.

Avatar

Employee Advisor

It's working fine when I use value from xml.

Sample.jpg

Try to use string or int type while inserting data. I encountered error while inserting date type, so I changed it to string type which was converted automatically.

Thanks,

Wasil

Avatar

Level 1

you store as String, what happens if you try to store as "date" in the Type column ?

Avatar

Employee Advisor

There was error but when I changed it to string , it worked !