• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to insert multiple selection from JSP to MySQL

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to know whether there is any mysql query to insert mulitple values taken from a jsp page... (Languages known : English, Spanish) into a single column. I mean, how do i insert both these values into the Language column in the database ?

Can anyone tell me the answer?
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer depends on your scenario. You can save it as a comma separated String. Not necessarily a JSP related question
 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give the exact query ?
I am using it in a JSP page... so thought I might tel it here...
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Best not write SQL statements in a JSP. A JSP is a view, nothing more.

Can you give the exact query ?



How can I give you one when I know nothing of the table details. It should be a trivial insert / update. I am sure you can figure it out
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rebecca Green wrote:...how do i insert both these values into the Language column in the database ?


You do not insert two values in a single column. You need to end up with only one value that contains all those languages: for instance, the string "English, Spanish". Or you could try to see if normalization would help you here (keep the languages in a different table that has a many-to-many relationship with the other table).
 
Rebecca Green
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the solution... rather simple one ;)
I just retrieved the multiple select values into a string array using getParameterValues and used another string array to store all these values (comma seperated). I then inserted this string into the database.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic