db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kent Spaulding <k...@iotabits.com>
Subject Re: timestamp and Derby/Oracle?
Date Mon, 02 Feb 2009 23:45:37 GMT
Thanks, I've headed down that path and it looks much more promising,  
if not painful.

--Kent

On Feb 2, 2009, at 3:33 PM, Stephan van Loendersloot (LIST) wrote:

> Kent Spaulding wrote:
>>
>> // assume INSERT_TIME is SQL type TIMESTAMP and FOO is type  
>> VARCHAR(100)
>>
>> INSERT into MY_TABLE (INSERT_TIME,FOO ) VALUES ( '2009-02-02  
>> 14:28:08.81', 'foo value')
>>
>> Not a problem in Derby; but Oracle complains about the month not  
>> being valid.  I expected Oracle to use the timestamp.toString() as  
>> input - how odd that it doesn't.
>>
>>
> Hi Kent,
>
> Try something like this, it should work for all drivers:
>
>
>
> PreparedStatement pstmt = conn
>   .prepareStatement("INSERT into MY_TABLE (INSERT_TIME, FOO) values  
> (?, ?)");
>
>   pstmt.setTimestamp(1, ts);
>   pstmt.setString(2, foo);
>
>   pstmt.executeUpdate();
>   pstmt.close();
>
>
>
> Regards,
>
>   Stephan.


Mime
View raw message