Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

trouble escaping quotes so I can use arraylist values to get recordsets

807601Feb 21 2008 — edited Feb 21 2008
My app is being built in tiny little baby steps.....

Thanks to the kind folks on this forum, I've modified the constructor for a class I have to accept an arrayList rather than series of strings. The relevant parts of the class are below.

Now, when I construct this class, instead of sending something like

chsShape(arraylistValue1,arraylistValue2,arraylistValue3...)

I need to construct it with infor pulled from a database. I previously had stuff hardcoded like the following, and it worked: chsShape(rs.getString("arraylistValue1"),rs.getString("arraylistValue2"),rs.getString("arraylistValue3...)")

You can see in the code below that I'm trying to escape the quotes so that they can be interpreted correctly to get info from the db. The result is that the quotes are not escaped, and my output has values like rs.getString(\"arraylistValue1\")

So once again, I am forced to turn to you ever-helpful folks.
public class chsShape {
	public ArrayList setInfo;
	public ArrayList getInfo() {
		ArrayList fields=new ArrayList();
		 for (int x=0;x<setInfo.size();x++){
			fields.add("rs.getString(\\\""+setInfo.get(x)+")\\\"");	
		 }
		return ((ArrayList)fields); 
	}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2008
Added on Feb 21 2008
14 comments
453 views