IBM developerWorks

Just me and the computers this weekend. I’ve not spent alot of time on IBM’s site, but developerWorks and alphaWorks (emerging technologies) are two really great sites. Not sure how often they update the site, but the Java technology directory on developerWorks has some nifty articles right now:

JDBC query logging made easy: “Add logging to your JDBC code with an enhanced PreparedStatement” This article shows you how you can implement the PreparedStatement interface, overriding default query behavior, to provide better debugging and logging facilities. I used PreparedStatements all over the place on karensrecipes.com, next rev I’ll be sure to add in a PreparedStatementLogging class. Also, the author mentions that the LoggableStatement class he’s written is a great example of the Decorator design pattern, which I wondering about a couple months ago.

Accessing SQL and XML content using JSTL: “Custom tag libraries for exchanging XML and database content in JSP pages” Looks like JSTL might be one or two revisions away from being as simple and easy to use as ColdFusion tags. Check out this JSTL SQL query example:

<sql:setDataSource var=”dataSrc”
    url=”jdbc:mysql:///taglib” driver=”org.gjt.mm.mysql.Driver”
    user=”admin” password=”secret”/>
    <sql:query var=”queryResults” dataSource=”${dataSrc}”>
  select * from blog group by created desc limit ?
  <sql:param value=”${6}”/></sql:query>

<table border=”1″>
  <tr>
    <th>ID</th>
    <th>Created</th>
    <th>Title</th>
    <th>Author</th>
  </tr>
<c:forEach var=”row” items=”${queryResults.rows}”>
  <tr>
    <td><c:out value=”${row.id}”/></td>
    <td><c:out value=”${row.created}”/></td>
    <td><c:out value=”${row.title}”/></td>
    <td><c:out value=”${row.author}”/></td>
  </tr>
</c:forEach>
</table>

Pretty close to a cfquery isn’t it?

Leave a Reply

Your email address will not be published. Required fields are marked *