DATE field problem in JSF code

Hi,

I am a newbie on JSF and working with a JSF application development. I have a problem with a data type: DATE. Here is what had happened; I tried to write a new record to a table, in my "write" paragraphs I have the following codes:

.....

tabelOneDataProvider.setValue("joindate", rowKey, joinDate1.getSelectedDate());

tableOneDataProvider.commitChanges();

......

The problem is when I was running the program to write a record, I got the following error:

Cannot append new tableOne data: java.lang.RuntimeException: Number of conflicts while synchronizing: 1 SyncResolver.INSERT_ROW_CONFLICT row 1 Can't infer the SQL type to use for an instance of java.util.Date. Use setObject() with an explicit Types value to specify the type to use.

At that point, I was trying to write a DATE value from a "calendar' component (joinDate1 field with MM/dd/yyyy format) into a field name: "joindate' (data type is DATE) in tableOne file.

Any advice on resolving this problem? Please help me to get more knowledge on this. Thanks!

[1085 byte] By [jsfNewbiea] at [2007-11-27 2:22:44]
# 1

Hi,

You must use sql type. So instead of:

tabelOneDataProvider.setValue("joindate", rowKey, joinDate1.getSelectedDate());

tableOneDataProvider.commitChanges();

try something like:

java.util.Date date = joinDate1.getSelectedDate();

java.sql.Date dateToInsert = new java.sql.Date(date.getTime());

tabelOneDataProvider.setValue("joindate", rowKey, dateToInsert);

tableOneDataProvider.commitChanges();

best regards

Grzegorz

Grzegorz.Kluczeka at 2007-7-12 2:27:33 > top of Java-index,Development Tools,Java Tools...
# 2
Hi Grzegorz ,Your solution is SUPERB!!!Thank you for your quick respond to my posting! GBU,jsfNewbiePS: It is nice to learn a new thing everyday.
jsfNewbiea at 2007-7-12 2:27:33 > top of Java-index,Development Tools,Java Tools...