What's the problem? your example works exactly as expected, but you haven't shown executing the ps.
Problem is, the result not my expected. The Preparedstatement.toString() should be return "select...where userid='someone'", but it return "org.jboss.pool.jdbc.PreparedStatementInPool@25491d", this is not my expecte statement.
This is comment isn't related to your problem, but you should create your string like this:
String _sqlString = SELECT " +
" b.subsysid, a.modid, a.rightsid " +
"INTO " + _tmpTbl +
" FROM usermodrights as a "
"LEFT JOIN module AS b USING(modid) " +
"WHERE userid = ? " ;
Your method will create a new string object(overhead) every time you do _sqlString + "someString". Whereas, the above statement should compile into StringBuffer.append(). Probably won't make a huge difference in performance, but there's no reason not to do it this way.
You are right, my code (production) also use StringBuffer and some myown query generation method, my piece of code, just for my debug to trace error... ;-)
About my problem, any idea?
I'll try again: What's the problem? Eveything you show is working fine. There are no specs for what PreparedStatement.toString() should return.
I had change my program, it work fine, thanks.
As early of my program , i use the preapredstatemet.tostring to return the compiled sting, for example,
1.) my_sql_statement="select * from table1 where pri_key = ?"
2.) set the parameter to "myid"
3.) preapredstatemet.tostring return = "select * from table1 where pri_key = 'myid'"
the return is what i want.
In jboss, it wrapped preparestatment and add to hash table (a helper say that), so when i call tostring, it return the "org.jboss.XXXXXX@1234". :-)
now i change my code directly use the preparestatment, it everything work fine.