• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing multiple values in the Database.

 
Pandurang Shenoy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am making use of a parameter in JSP that has multiple values(say 3 different values). I want to store all the values of that parameter in the DataBase under a single column.How can i do that..?If you know,please let me know..
Regards
Pandurang
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
given an existing Connection con

i didn't test it, but it should work
cb
 
Rajeshwari Natarajan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But by Christian Baron's code u'll be trying to execute multiple insert statements.
Create a delimiter separated string with all the values u want to insert and then call an insert statement.
[ April 03, 2003: Message edited by: Rajeshwari Natarajan ]
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to use the SQL statement many times but with different values you should really use a PreparedStatement rather than a statement. It is a lot faster as the DB doesn't need to re-parse the SQL statement.
Example shown below:
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaah,
i was allways wondering what PreparedStatement was good for. Learned something.
thx Andy
 
Pandurang Shenoy
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx to all for replying to my Qn..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!