This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to insert multiple check box data into database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to insert multiple check box data into database" Watch "how to insert multiple check box data into database" New topic
Author

how to insert multiple check box data into database

mallikarjun dontamsetti
Ranch Hand

Joined: Mar 18, 2011
Posts: 244

I want to insert multiple check box data into database

String[] rval = request.getParameterValues("r");
used t get the values and i have to append , between each one and insert them into single column.


After that if i want to edit data then i have to get that data and show them in related check boxes to be checked


thanks.
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1190
    
    1

your problem seems to be pretty straight forward. Are you looking for exact code to achieve your requirements ?

simple steps could be

1. define your table column as VARCHAR2 type.
2. grab the value of multple checkbox recieved from browser (variable - rval as shown in your post)
3. you can use String concentation operator to append comma between check box values
4. now update that string in table column

for showing that check box data back again,
1. fetch the table column value from database
2. tokenize the string using StringTokenizer using comma as seperator
3. send these individual check box value to jsp page using request or session

 
jQuery in Action, 2nd edition
 
subject: how to insert multiple check box data into database