I am having a problem using the java.text.MessageFormat object.
I am trying to create SQL insert statements. The problem is that when I do something like this:
MessageFormat messageFormat = "insert into {0} values ( '{1}', '{2}', '{3}', {4} )"; Object[] args = { str0, str1, str2, str3, str4 }; String result = messageFormat.format(args);
I get this result value:
"insert into <str0> values ( {1}, {2}, {3}, <str4> )"
As you can see, the problem is that any of the target locations enclosed in single quotes is not replaced by arguments. I tried using double single quotes like this: ''{1}'' and escaped characters like this: \'{1}\' , but it still gives the same result.
edit: I forgot to mention that I also tried '''{1}''' . Result: "insert into <str0> values ( '{1}', '{2}', '{3}', <str4> )" . "insert into <str0> values ( '{1}', '{2}', '{3}', <str4> )" It retains the original quotation marks, but does not insert values.
How can I solve this problem? For recording, I use JDK 6u7.
java
TM Oct 10 '08 at 2:15 2008-10-10 02:15
source share