-
1. Re: Problem!!! Prepare statement in ejb.
davidjencks Dec 30, 2001 12:41 AM (in response to gordonlch)What's the problem? your example works exactly as expected, but you haven't shown executing the ps.
-
2. Re: Problem!!! Prepare statement in ejb.
gordonlch Dec 30, 2001 1:22 AM (in response to gordonlch)Hi david,
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.
Gordon -
3. Re: Problem!!! Prepare statement in ejb.
armint Dec 30, 2001 1:30 AM (in response to gordonlch)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. -
4. Re: Problem!!! Prepare statement in ejb.
gordonlch Dec 30, 2001 1:37 AM (in response to gordonlch)Hello armint,
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?
Gordon -
5. Re: Problem!!! Prepare statement in ejb.
davidjencks Jan 1, 2002 9:09 AM (in response to gordonlch)I'll try again: What's the problem? Eveything you show is working fine. There are no specs for what PreparedStatement.toString() should return.
-
6. Re: Problem!!! Prepare statement in ejb.
gordonlch Jan 3, 2002 11:27 AM (in response to gordonlch)Hi davidjencks,
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.
Gordon