aspose file tools*
The moose likes JDBC and the fly likes JDBC and null dates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC and null dates" Watch "JDBC and null dates" New topic
Author

JDBC and null dates

Chuck Cabrera
Greenhorn

Joined: Jan 20, 2002
Posts: 9
When inserting a record from my jsp page into Sybase my date is displayed as Wed Dec 31 16:00:00 PST 1969. The date field is blank on my jsp page but the database requires a value on insert. I am using the pPreparedStatement ps.setNull(1,java.sql.Types.Date) I really want the date to be null in the database. How can I get past this value being displayed in the database?
Thanks.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Chuck
If the database table is set up not to accept null values for that particular column then you'll have to find some other way around it (or have the schema of the DB changed). Maybe insert a value that you know wont be entered in normal use to represent null ?


Dave
Chuck Cabrera
Greenhorn

Joined: Jan 20, 2002
Posts: 9
Thanks Dave. I'll go for inserting a value that can't be used for normal business.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC and null dates
 
Similar Threads
Resultset based on current Date and Time
Date Format
Converting "Mon Nov 24 00:00:00 EST 2008" pattern to "dd/MM/yyyy" pattern
Date Formatting
problem insering date value in database