Sunday, October 23, 2005

Finally no more clob-clipping: Oracle 10g supports standard JDBC CLOB-handling

The new enhancements in Oracle JDBC 10g promises to simplify the insertion and retrieval techniques for the CLOBs using the standard APIs.

Handling Clobs in Oracle 10g

Just discovered the above link after trying to use Oracle's thin JDBC-Driver with Hibernate to save CLOB-data ... This automatically and silently nullifies the CLOB-field when you try to save more then 4k to it which you are likely to do -- after all it's called a cLob.

Now, finally this seems to be fixed in the 10g-JDBC driver. Up to now, it seems to work fine with our somewhat dated 8i installation. Keep my fingers crossed that it stays that way. I'd hate having to resort to the fat oci-driver ...

Wednesday, October 19, 2005

Apache DBCP - never forget maxWait

Had some not so cozy hours debugging a productive app on Tomcat. The thing would spontaneously hang about once a day (The whole of Tomcat, apart from JMX was completely hung). It hung in an infinite wait in the Database-Pool. Funnily the default of the maxWait-Param is "-1", i.e. infinitely. Now, after I fixed this it runs nicely.
But it's still not clear to me, where the total deadlock came from... Maybe some thread which would not release it's connection before it got another one (to a different DB).

Wednesday, October 05, 2005

The Scattered State-Machine - An Antipattern for Web-Controllers

Like a lot of popular anti-patterns the scattered controller stems from the naive implementation of a seemingly obvious abstraction. The reasoning goes like this: Web-Apps show some html-page, each user event (http-request) triggers an action which, in turn, results in an event determining the next state which is either an action or a an html-page transferred back to the user's browser. So, use the old recipe for desaster: Make each noun of your problem description a class, let the resulting "state-machine" be "declaratively" defined using obscure tables or, more fashionable, xml (ok, luckily, xml is not that fashionable anymore). - And voila, you did it. You've polluted your whole controller with a verbose, scattered "state-machine", the internal workings of which are distributed across a host of artifacts: page-template, action-classes, state-machine-spec, events. And most of the time, all you want to do is: Just call a method and display the results ...

Struts apps are particularly notorious for this Anti-Pattern. If you want to know just how complicated you can make the good old library-search scattering your event-urls not only throughout jsp, java-code and struts-config but also through a spring context, see this ibm-dev-works article