use to_date or to_char in sql to format your date in Oracle.
Example:
strSQL = "insert into document(id,filename,datetimestamp)
values('"+docID+"','"+filename+"','MON DD, YYYY HH:MI:SS AM'))";
String strSQL = "select id,filename,to_char(datetimestamp,'YYYY-MM-DD
HH:MI:SS') as datetimestamp1 from documents";
Kevin
-----Original Message-----
From: Keith Wall [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 16, 2001 10:14 AM
To: [EMAIL PROTECTED]
Subject: Re: Prepared Statement and date
The default input/output date format picture used in Oracle is DD-MON-YY.
(eg. 16-MAY-2001). "2001-05-16 10:10:10" doesn't look like DD-MON-YY so
Oracle throws the statement out.
You could reformat your date-string to use the default picture, or
change the format Oracle expects to receive date strings.
The DD-MON-YY default can either be changed server wide, or on a per-client
session basis (read-up about NLS_DATE/NLS_DATE_FORMAT). You most likely
want the latter.
On Wed, May 16, 2001 at 10:42:28PM +0800, Albert Yip wrote:
> Hi all,
>
> Just wondering about how should I deal with dates when trying to insert
data
> into db with prepared statements. I tried to use strings like "2001-05-16
> 10:10:10" but it keeps giving me error:
>
> java.sql.SQLException: ORA-01861: literal does not match format string
>
> any ideas? I would really appreciate it if someone can give a hand.
>
> Thanks,
> Albert
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
--
Keith Wall.
http://www.beenz.com/
beenz.com (uk), 131-151, Gt. Titchfield St, London.
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html