I really can’t find a nice enum JDBC mapping example.
Is enum actually supported by JDBC?
I am working with MySQL. I have an enum column, and would like to map to some Java enum.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JDBC does not support enums.
You can convert a string to an enum though, so if you have a Java enum you can do something like
You’ll have to keep your java enum and mysql enum in sync though. MyEnum.valueOf() can throw IllegalArgumentException if there’s no mapping from the string, or NullPointerException if you get a null value from the db.