Reputation: 3
Java MySQL Database I'm doing a project on saving a string which is a path name like, "C:\Desktop\" into the database. I had create a entity class to update this path name into database, in java eclipse when i run my program it display the path is store in the database in this format, "C:\Desktop\" but in the database column for this path it only store "C: Desktop", without the '\'
Upvotes: 0
Views: 707
Reputation: 1508
A simple solution is to replace the the "\"
before you store it in the database. Try:
string.replace("\","@");
Then your slashes are the @
symbols. When you read the value again, you can do it the other way.
Upvotes: 0
Reputation: 35587
Simplest solution is use /
instead of \
in path . Or escapes the characters in a String using Java String rules
Upvotes: 1
Reputation: 68715
You need to escape the \
with \\
. Use this to store
C:\\Desktop\\
instead of
C:\Desktop\
Learn more about escape sequence in java : http://docs.oracle.com/javase/tutorial/java/data/characters.html
Upvotes: 1