JDBC/Oracle date conversion

From: Andrei Adamchik (aadamchi..obox.com)
Date: Thu Jul 05 2001 - 22:25:50 EDT


Guys (especially those who work with Oracle):

Here is an SQL statement that I am trying to execute:

INSERT INTO EXHIBIT
(EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE)
VALUES (4, 99, '2001-07-05 21:35:04.835', '2001-07-12 21:35:04.835')

Oracle (both JDBC and sqlplus) complains about the date format:

ORA-01861: literal does not match format string

Ok, in sqlplus I can run something similar to:

INSERT INTO EXHIBIT (EXHIBIT_ID, GALLERY_ID, OPENING_DATE, CLOSING_DATE) VALUES
  (4, 99, to_date('2001-07-05', 'YYYY-MM-DD'), to_date('2001-07-12',
'YYYY-MM-DD'))

and things will be fine, but what about JDBC? how in the world can I tell
the driver what date format to expect? (I am using thin JDBC driver, not
OCI)... there should be a generic approach that I somehow overlooked. (Not
to mention that the same statement works just fine with Sybase)

Any ideas?

Andrei



This archive was generated by hypermail 2b30 : Sat Aug 04 2001 - 16:21:25 EDT