embedding spaces in java

I have the following declaration:

List<String> commandList = new ArrayList<String>(){{
        ...
       add("last_name=\"Test User\"");

   }};

I want to make sure Test User is inserted into my database w/o the quotes but its not working.  Any ideas?
chuckster_ehAsked:
Who is Participating?
 
zzynxSoftware engineerCommented:
Your java code looks OK.

Question is: what does the code that is responsible for the database insert do with the command:

                    last_name="Test User"


>> I want to make sure Test User is inserted into my database w/o the quotes
>> but its not working.
Do you mean that it is currently inserted with the quotes?
Then why not trying:

        add("last_name=Test User");

Open in new window

0
 
käµfm³d 👽Commented:
Without seeing your database code, it would be difficult to tell you where you're going wrong. Make sure you are single-quoting your strings that go to the database.

e.g.

string toDatabase = "'Test User'";  // single quotes surrounding string; double-quotes surrounding single quotes

Open in new window

0
 
CEHJCommented:
I want to make sure Test User is inserted into my database w/o the quotes
Why not just replace them then?

s = s.replaceAll("\"", "");

Open in new window

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
ValeriCommented:
probably the value is taken in this way...?!?!
String[] arrValues = theWholeString.split("=");
and arrValues[1] is inserted to database, so try with this line, the same like original one, but without the quotes :
add("last_name=Test User");
0
 
zzynxSoftware engineerCommented:
@Valeri: that's exactly what I said in the previous comment
0
 
ValeriCommented:
@zzynx: yes, it's almost the same! if this is the case you will be the awarded one, because you were the first one with the idea! :-)
I wrote this because sometimes it's not easy for the begginers to trace the code in the way that experienced developers can.
0
 
chuckster_ehAuthor Commented:
Thank you.  This was the syntax that ended up working for me.
0
 
CEHJCommented:
Q. How do i get a string inserted into the db without quotes
A. Don't put them in

;)
0
 
chuckster_ehAuthor Commented:
very true it turned out to be in this case.   :)
0
 
zzynxSoftware engineerCommented:
Life can be easy ;-)
Thanx 4 axxepting
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.