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
Asked
Active
Viewed 1,276 times
-2
-
It depends how your column is defined. If you need null values, make the column nullable, else you are forced to provide a date. – Landei Sep 22 '17 at 09:40
-
If the question is unclear just dont react anything – Karthik P Sep 22 '17 at 11:04
-
I have tried making column nullable and also tried with default constraint but not worked – Karthik P Sep 22 '17 at 11:05
2 Answers
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.