inserting multiple selection from checkbox in to one column

Reply

Join Date: Mar 2006
Posts: 20
Reputation: muthumari is an unknown quantity at this point 
Solved Threads: 0
muthumari muthumari is offline Offline
Newbie Poster

inserting multiple selection from checkbox in to one column

 
0
  #1
Mar 30th, 2006
Hi,


Hoe to insert multiple selection from checkbox(from jsp) in to one column of the table(sql server database ).


Anyone can you help me?

Thanx
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: inserting multiple selection from checkbox in to one column

 
0
  #2
Mar 30th, 2006
With a prepared statement and multiple executes.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 20
Reputation: muthumari is an unknown quantity at this point 
Solved Threads: 0
muthumari muthumari is offline Offline
Newbie Poster

Re: inserting multiple selection from checkbox in to one column

 
1
  #3
Mar 30th, 2006
Originally Posted by masijade
With a prepared statement and multiple executes.



Hi,
Thanx for your reply . I know, how to retreive the checkbox value(using prepared statement with request.getParameteVales("checkboxname")).



But, It will return an array of values.
I don't know about how to insert this array of values into single column of the table(sqlserver database).
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: inserting multiple selection from checkbox in to one column

 
0
  #4
Mar 30th, 2006
No What I meant was using the JDBC prepared statement. here an example:

  1. String[] vals = request.getParameterValues("checkbox");
  2. try {
  3. PreparedStatement pStmt = conn.prepareStatement("Insert into table (field) values (?)");
  4. for (String val : vals) {
  5. pStmt.setString(1, val);
  6. pStmt.execute();
  7. }
  8. } catch .....

of course replacing checkbox, table, and field with the real things.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 20
Reputation: muthumari is an unknown quantity at this point 
Solved Threads: 0
muthumari muthumari is offline Offline
Newbie Poster

Re: inserting multiple selection from checkbox in to one column

 
0
  #5
Mar 30th, 2006
Originally Posted by masijade
No What I meant was using the JDBC prepared statement. here an example:

  1. String[] vals = request.getParameterValues("checkbox");
  2. try {
  3. PreparedStatement pStmt = conn.prepareStatement("Insert into table (field) values (?)");
  4. for (String val : vals) {
  5. pStmt.setString(1, val);
  6. pStmt.execute();
  7. }
  8. } catch .....

of course replacing checkbox, table, and field with the real things.


Hi i have one error in this line:

pStmt.setString(1, val);


The error is ; expected.
I haven't any idea about this

Can you help me
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,415
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 256
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: inserting multiple selection from checkbox in to one column

 
0
  #6
Mar 30th, 2006
Are you using jdk 1.5 or an earlier version. If you are not using 1.5 then the following lines
must be changed:

  1. for (String val : vals) {
  2. pStmt.setString(1, val);
  3. pStmt.execute();

to:

  1. for (int i = 0; i < vals.length; i++) {
  2. pStmt.setString(1, vals[i]);
  3. pStmt.execute();
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: alokranjan.java is an unknown quantity at this point 
Solved Threads: 0
alokranjan.java alokranjan.java is offline Offline
Newbie Poster
 
-1
  #7
Oct 15th, 2009
multiple checkbox & textfield insert in Oracle9i using Jsp
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,206
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer
 
-1
  #8
Oct 15th, 2009
Originally Posted by alokranjan.java View Post
multiple checkbox & textfield insert in Oracle9i using Jsp
It is bad enough that you reopened old thread you did not even provided proper description of whatever you up to. Do you mind to correct your mistake?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC