Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ORA 01861 - literal does not match format string

 
pallavi Battini
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34383
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
pallavi Battini
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic