Stored Procedures

Andres Aguiar had a recent post on Stored Procedures vs. direct queries.  This has been a hot topic at work lately, and aside from my recent learning experiences with DB2, I can't speak with any authority on other DB's support for stored procs.  However, when he said

Java programmers seldom use stored procedures. They are not portable, it breaks the ‘write once run anywhere’ motto

it brought to mind a recent quote in the whole .NET vs J2EE pet store brouhaha, something like "Sun recommends direct queries, but that's stupid".  And this was coming from someone on the J2EE side of the debate.  So this comment is a little perplexing.  As I mentioned, my cross platform DB experience is pretty minimal (even when I was doing Java a couple years ago, it was against SQL Server), but it seems like by doing direct queries, you're throwing out a lot of potential optimizations at the database level that could otherwise be hidden behind stored procs. 

— Gordon Weakliem at permanent link