Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

retrieve enumeration datatype into jsp

 
priya pratheepp
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi firends,

I am using MYSQL In my table i have enumeration data feild.I want to retrieve that data field into jsp page recordset.---- ?

can you please help me
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by an enumeration data field?
 
priya pratheepp
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
enum
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, an enum data type?

This data type in MySQL is just character data; have you tried calling ResultSet.getString()?
 
priya pratheepp
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks...using getString i can retrieve only one value....

any other data types can do the same task?

for example data values are SG10,SG20,HK10,CN10 like that...each variable can have more than one value..example branch may have SG10,HK20 etc...Any suggestion to handle this situation?

thank you once again
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation for the enum data type includes ways to do this. All PHP, but the logic will be the same in Java.

Personally, I would use a seperate table to store the enumerated values and a foreign key to refer to them and just not bother with the enum data type. I can't see how it is useful without being able to get the values easily in a non-database specific way (that way you don't have to change your Java code if you start using a differernt database).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic