Tuesday, January 31, 2006, 3:03:38 AM CET, Craig L Russell wrote: > Hi John,
> On Jan 30, 2006, at 12:11 PM, John Embretsen wrote: [snip old quotes] >>> Any reason why itemID is bound to the preparedStatement and not >>> itself passed as a parameter? >> >>> Generally, preparing statements like this (those that include >>> parameters) just before use has little benefit. The big win is to >>> prepare the statement and then reuse it everywhere. So if you change >>> the updateBidItemSQL to include the itemID as a ? parameter, then >>> pstmt.setInt(3, itemID) you will get the benefit of prepared >>> statements. >> >>> Craig >> >> I am fully aware of this rather strange and inefficient use of >> PreparedStatements in the DOTS test case. As I stated in my first E- >> mail >> in this thread: >> >> "I don't know the rationale behind doing it this way. It may be just >> "sloppy code", or it may be intentional." > I was trying to be nice. I'll reiterate my point. If your use of > prepared statements is limited to the following pattern: > PreparedStatement ps = conn.prepare(savedSQLStatement + "" + itemID + > ""); > ps.setInt(...); > ps.execute(); > then you are not taking advantage of prepared statements. Your > prepared statement cache is not doing any good at all. I hope I have not given anyone the impression that I am an advocate for such use of PreparedStatements. I am not. I am testing Derby, and the purpose of testing Derby is to find faults in Derby, so that they can be fixed. Sure, changing or not running these tests will make the symptoms go away, but is that a good long term strategy for Derby? Do we have any guarantees that other users of Derby (directly or indirectly) will not stumble across this or similar memory leaks in the future, when the costs of experiencing and fixing such bugs may be a lot higher? > This is the hammer that is making your head hurt. Before you can see > if aspirin helps, put down the hammer. Personally, I would prefer a database with a strong enough helmet to withstand such hammer hits. Someone else may find that hammer one day, and hit you again ;) -- John
