0 Replies - 683 Views - Last Post: 05 May 2017 - 04:07 AM

#1 karengsh  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 132
  • Joined: 18-May 09

how to do the PreparedStatement for Arrays or ArrayList?

Posted 05 May 2017 - 04:07 AM

Dear expert,


I have a table name tutor where one of the column named subject has mulitples values.

First, I have a jsp form and user can tick as many checkboxes, and the values will go into the subject column of my table - tutor in the database.

But, I do not know how to set and get the subject in order for the values of the checkboxes to be inserted into database.

Note : I am leaving out the connection and sql here.

 ps.setString(13,  m.getRemark());
	      	List<String> list =  Arrays.asList(m.getSubject());			
	        ps.setArray(14, (Array) list);	  // ps is the PreparedStatement      	



m4.setRemark(remark);			
			String[]subject = request.getParameterValues("subject");	
			int i = 0;
			for (i = 0; i < subject.length; i++)
			m4.setSubject(subject);	
			i++;
			out.println(subject + " ");	



Hope someone can tell me how to.

Tks.

This post has been edited by karengsh: 05 May 2017 - 04:08 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1