Field 'class' doesn't have a default value
It seems that it is MySQL error 1364 - Message: Field '%s' doesn't have a default value.
Check the table which you modify. Are there any fields without default values? Also analyze INSERT and UPDATE statements if they do not post these field values.
To fix this error:
- modify table - set DEFAULT values for fields you need
or
- pass concrete values to these fields in INSERT/UPDATE statements.
Fustigador
Former cameraman, now developing apps for Android. Drummer, DM and Android developer (in that order)
Updated on June 13, 2022Comments
-
Fustigador almost 2 years
In our app, I have a class describing a person (eye and hair colour, height, etc). Once the form of registering is fulfilled, I click in the submit button, and an exception is thrown:
Class: java.sql.SQLException Message: Field 'class' doesn't have a default value
I am scratching my head about this, because none of the classes have a field named class, for obvious reasons (it's a reserved word), and in the database there is no column named class, neither.
Any idea why this happens? And how to fix it?
EDIT:
I tried this:
classThrowingExceptionInstance.class=ClassThrowingException
And now it says Cannot set readonly property: class for class ClassThrowingException
-
Fustigador over 11 yearsThank you! Looking for closely (it is inherited code, and an inherited database) I found that the class throwing the exception extends another class (let's say, User) wich does not have a property called class, but in the Database it HAS a column named that way. Guess i should set a default value for that column.
-
Devart over 11 yearsLook for one more time ;-) This is MySQl error. You should find all errors and fix them.
-
Fustigador over 11 yearsI finally droped the entire database (we are not yet online), and Hibernate created it again. And now works fine. Thank you Devart :)