Date - Java
Hello All,
while inserting a record into the database...i have a requirement to insert today's date in one of the column ... and I'm doing something like this :
stmt.setDate(1, new java.sql.Date(Calendar.getInstance().getTime().getTime()));
but getting the ORA-01843: not a valid month error but when I try
System.out.println( new java.sql.Date(Calendar.getInstance().getTime().getTime()));
I'm getting the output as '2007-06-06'
Help is greatly appreciated...
Thanks,
Greeshma...
If you are using SQL "Insert" statement statement you may try to insert "sysdate" in the Today's date field.something along the lines :INSERT into Table_1(...., today_date, ... ) values( ... , sysdate, ... )
vs777a at 2007-7-12 18:08:36 >

Here are some thoughts:
Printing out the java.sql.Date value via the toString method won't really tell you much since it prints to the format yyyy-mm-dd and it doesn't tell you what is going on when the Date goes through the driver.
I'd check is the attribute type you are trying to set. Are you sure it's wanting something that Date can provide? You can also check the date format by issuing:
select * from nls_session_parameters
and look at the NLS_DATE_FORMAT column.
As a last resort you could use a SimpleDateFormat to format the date the way it needs to be done and then do a setString on the column instead of a setDate.
Hope they help.