db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephan van Loendersloot (LIST)" <step...@republika.nl>
Subject Re: timestamp and Derby/Oracle?
Date Mon, 02 Feb 2009 23:33:25 GMT
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