• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resource file - add quotes around param

 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're passing those resources into MessageFormat.format(), you need to use two single quotes, e.g.

 
Chris Montgomery
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perfect!

Thanks Brian.

Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic