aspose file tools*
The moose likes JDBC and the fly likes  ORA 01861 - literal does not match format string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark " ORA 01861 - literal does not match format string" Watch " ORA 01861 - literal does not match format string" New topic
Author

ORA 01861 - literal does not match format string

pallavi Battini
Greenhorn

Joined: Feb 25, 2008
Posts: 2
Hi

Actually i am trying to insert a date value into a oracle table its giving the following exception ORA 01861 - literal does not match format string.

The code is here:

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

insertData = con.prepareStatement("INSERT INTO FRQ.t_prc_rqst VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)");
insertData.setString(2,"commentfield");
insertData.setString(3,dateFormat.format(loadGroup.getStartDate()));
.................
insertData.execute();

Can anyone tell me which date format is supported by oracle 9.I almost tried all kinds of formats..and fed up.
This code snippet is from a webservice written using jboss seam.

Help is much appreciated.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

Pallavi,
Welcome to JavaRanch!

One of the benefits of prepared statements is not having to jump through datae format hoops when you could just do:
insertData.setDate(3,loadGroup.getStartDate());


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
pallavi Battini
Greenhorn

Joined: Feb 25, 2008
Posts: 2
hi jeanee
That works if the date from dto is java.sql.Date but what we have is java.util.Date

It finally worked when i converted this util.Date to sql.Date using valueOf method.
Thanks for the response.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ORA 01861 - literal does not match format string