File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes resource file - add quotes around param Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "resource file - add quotes around param" Watch "resource file - add quotes around param" New topic
Author

resource file - add quotes around param

Chris Montgomery
Ranch Hand

Joined: Jan 14, 2004
Posts: 141
I have a resource file (x.properties) that I'm storing all my sql statements in.

how do I get single quotes around a parameter in my properties file?

properties file:
test.sql=SELECT * FROM member WHERE member_name={0}

How do I get the above to output this:
SELECT * FROM member WHERE member_name='CHRIS'

I've tried:
test.sql=SELECT * FROM member WHERE member_name='{0}'

and :
test.sql=SELECT * FROM member WHERE member_name=\'{0}\'

but both return
SELECT * FROM member WHERE member_name={0} rather than what I want.

perhaps my approach is wrong...



Thanks!
Brian Duff
Greenhorn

Joined: Aug 16, 2001
Posts: 22
If you're passing those resources into MessageFormat.format(), you need to use two single quotes, e.g.

Chris Montgomery
Ranch Hand

Joined: Jan 14, 2004
Posts: 141
Perfect!

Thanks Brian.

Chris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resource file - add quotes around param