I am trying to update as well as save data to my database using my GUI. My problem is, if i don't enter any data to certain textboxes which i have allowed null on my database, i get this kind of error: java.sql.SQLException: Data truncated for column 'MonthlyIncome' at row 1
Typically this problem occurs when you are putting in a data that is too long for the column. In this case, whatever data you are updating the 'MonthlyIncome' field with is too long.
Another reason why this error could occur is when the type of your column is an ENUM with a limited list of values but you are trying to insert something that doesnt belong in that list.
For instance, if your column type is ENUM ('XXX','YYY','ZZZ') but you are trying to insert a value 'AAA' into this column, you'll get the same error.
If you are using Hibernate, then another reason might be you're missing @Enumerated
annotation. Annotate it with your desired data type like the example below :
@Column(name="monthly_income")
@Enumerated(EnumType.STRING)
private MonthlyIncome monthlyIncome
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With