Reputation: 1140
If i didnt get value for created_date it throws mysql errror. How To solve this problem?
var query1 = "INSERT INTO prospect_group(
group_name,status_id,created_date,
is_eligible,mom_active_fromdt,
mom_is_savings_discussed,
is_full_attendence,is_internal_loan) VALUES
('"+groupNameArray[0]+"', '"
+groupNameArray[14]+"', '"
+groupNameArray[1]+"', '"
+groupNameArray[15]+"','"
+groupNameArray[7]+"','"
+groupNameArray[8]+"','"
+groupNameArray[9]+"','"
+groupNameArray[10]+"' )";
Upvotes: 2
Views: 895
Reputation: 15723
Setting created_date
field default value to Null
or
Use zeroDateTimeBehavior=convertToNull
in the JDBC connection
example:
jdbc:mysql://192.168.6.1/test?zeroDateTimeBehavior=convertToNull
Reference: handling DATETIME values 0000-00-00 00:00:00 in JDBC
Upvotes: 1
Reputation: 1285
If you can add NULL set default value to NULL for created_date column and make sure that while you insert into table you'll have either date or null.
Upvotes: 0
Reputation: 11028
Something like this (setting the default value for the created_date field): MySQL timestamp only on create
Upvotes: 0