This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: resource file - add quotes around param
 
Similar Threads
how can i get the path from which resource bundle gets its bundle file
getting placeholder value dynamically in struts 1.2.9
Dynamic SQL with JDBC
Variable column name in PreparedStatement
JDBC querys from directory