Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / August 2007

Tip: Looking for answers? Try searching our database.

BITs or INTEGERs? (J2EE EL related)

Thread view: 
David Green - 15 Aug 2007 23:45 GMT
Currently I have a fairly large SQL table. Half way through it is an integer
field that I'm using to represent 5 checkboxes on a JSP form. The reason I
used a single INTEGER instead of many BIT fields is I could well be adding
more checkboxes later, and I don't really want to see the new fields
somewhere other than next to the 5 existing ones.

Now I started to doubt this approach when I realised that Sun's EL for JSP
pages doesn't cater for the bit operators. The following won't compile:

<c:if test="${(myflags & 0x01) == 0x01}">

So to get around this I have to just use a scriplet, i.e.:

<c:if test="<%= (myflags & 0x01) == 0x01 %>">

It still leaves a bad taste in my mouth though and makes me wonder if
there's a better approach, so I'm asking for advice here. Maybe I shouldn't
get attached to having the SQL look nice and ordered, in favour of more
readability in the Java? (Incidently, the 0x01 shown here is represented by
a static constant in my code for readability).
David Green - 16 Aug 2007 03:24 GMT
I think I answered my own problem by just writing it out.

I think I'll use SQL BIT types, which means I might end up in the sad
situation of an SQL table like:

NAME
AGE
FLAG_A
FLAG_B
FLAG_C
FLAG_D
FLAG_E
OCCUPATION
FLAG_F

with flag_f on its lonesome.. but I think it's worth it to avoid bit
manipulation in the Java.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.