Saving Enum in the Database MYSQL

I insert a row in the table as follows

final SqlParameterSource namedParameters = new MapSqlParameterSource.addValue("xParam", X.getName).addValue("yParam", Y.getName).addValue("zParam", Z.getName);

I have a enum colum in the database which is of enum OrderStatusEnum

I have an enum as follows

public enum OrderStatusEnum {
    ACTIVE("A","Active Order"),
    AWAITING("I","Awaiting Order")

I want to save ACTIVE, AWAITING in the database. Also retrieve the same on query

I'm facing exception when entity is getting set as enum and saved via JdbcTemplate. Data Truncate exception


1. Do i need to save ACTIVE/AWAITING in the database or Active Order/Awaiting Order i.e enum description ??
2. How to save the enum value and not sure how to save it

If i put Types.VARCHAR as an additional parameter the value is getting saved as ACTIVE/AWAITING ORDER and seems description is getting saved

Which one is the right approach - saving enum value or description. I think saving enum value would be the right option. However unable to save the enum using the above

Software ProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.