• Post Reply Bookmark Topic Watch Topic
  • New Topic

error:literal does not match format string  RSS feed

 
Vav Priya
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,i'm trying to insert some data of type date into database table using hibernate.i take the input date from an xhtml form as shown below

addEvent.xhtml


this is my addEvent method in EventBean.java


add method in EventDAO.java



while executing this..i get the following error: ORA-01861: literal does not match format string
could it be due to any mismatch in date format( chrome browser automatically takes date in the format mm-dd-yyyy )? if yes, how do i resolve it? (i'm using Oracle database)
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using JSF standard tag to generate those client, what is the type of eventBean.eventDate, string or date? I recall it needs to be string in the backing bean.

What's with the p:required and p:type? From primefaces?

I don't recall if JSF has way to format date, I used jquery's datepicker to do the formatting.

Also when inserting to Oracle database, the date field should be yyyy-mm-dd for it to work, or Oracle will complain it's not a proper date.

Given your situation, may fixing the sql to take in yyyy-mm-dd may do the trick.
 
Vav Priya
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for that reply. i used the following command for setting the date format.



now i'm getting the following error:
ORA-01843: not a valid month

 
Tim Holloway
Bartender
Posts: 18716
71
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Tsang. I use a third-party calendar control for my date/time data. However, unless I mis-remember, you can use a java.util.Date property for an inputText control provided you use a formatDateTime converter. Which, incidentally, will help in ensuring that the month/day/year input data is at least somewhat valid.

I do NOT, however, recommend using an actionListener to handle commands in JSF. Just use the POJO "action=" method instead. There is a legitimate use for actionListener, but it's so obscure that I cannot recall ever using it in 10 years of JSF.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!