-2

I am setting java object, having one property/field with an empty string. I am passing that java object to ibatis to insert in database. In database, table having a column with 'date' type. I am trying to insert empty string into that column but it is inserting some random values like '1900-01-01'. I have tried with setting null and more but nothing is possible. Help me out with the solution

Karthik P
  • 21
  • 2
  • 12

2 Answers2

0

if there is no value inserted, the default value should be null,empty In the table definition, make this datetime column allows null, be not defining NOT NULL:

Or, you can make use of the DEFAULT constaints:

syntax-DateColumn Date DEFAULT NULL

The beginner
  • 624
  • 4
  • 17
0

This issue is about Java, not SQL Server. You can't assign null to the Date variable - check this question. I suggest you can just don't pass this column and create DEFAULT constraint for it in the database.