java - How to combine two arraylists into one arraylist and pass it to procedure -


i need , assistant in combining 2 arraylists new arraylist passed procedure. once user selected certificates type list, stored in:

private list<string> selectedtypeacertificates = new arraylist<string>(); 

and once user selected certificates type b, stored in:

private list<string> selectedtypebcertificates = new arraylist<string>(); 

now in procedure need pass 2 string variables. 1 staff code , other selectedtypes both types & b.

callablestatement callablestatement =     connection.preparecall("{call processcertificates(?, ?)}");  callablestatement.setint(1, staff_code); callablestatement.setstring   (2, ); //i need pass selectedtypebcertificates & selectedtypeacertificates 

you can add elements both lists newly created one, , use stringbuilder build string in order pass procedure:

list<string> selectedcertificates = new arraylist<string>(); selectedcertificates.addall(selectedtypeacertificates); selectedcertificates.addall(selectedtypebcertificates);  stringbuilder sb = new stringbuilder(); (string cert : selectedcertificates) {     sb.append(cert);     sb.append("','"); }  string certificatesstring = sb.tostring(); if(!certificatesstring.isempty()) {     certificatesstring = "'" + certificatesstring.substring(0, certificatesstring.lastindexof(",")) + "'"; } 

the last couple of lines there remove trailing comma. of course might need change if procedure expects string in different format.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -