From the category archives:

Java

Apple’s Port of Java Deprecated!!

by Bruce on October 25, 2010

Apple has deprecated their port of Java.  Spencer’s thoughts on the topic are insightful.  I don’t recall Apple changing their mind very often so hopefully someone steps in to fill the void before it becomes a problem for us Java developers.  Fortunately we have some time.

{ 0 comments }

http://blog.springsource.com/2009/11/17/spring-3-type-conversion-and-validation/

{ 0 comments }

JPS JSTL formatting a number

by Bruce on August 2, 2010

http://www.jsptutorial.net/formatting-number-with-jstl-fmtformatnumber.aspx

An example:

<fmt:formatNumber value="${ae.minAge}"
                   type="number"
      minFractionDigits="0"
                    var="formattedMinAge"/>
<form:input type="text"
            path="minAge"
           value="${formattedMinAge}">

{ 0 comments }

JDBC: Pass a List to a jdbc parameter

by Bruce on June 14, 2010

If you have a List and want to pass it to a JDBC query as a parameter, try this. In this example we have a list of widget names and we want in return a list of store Id’s. For the sake of this example we are not looking to associate which stores sell which widgets. We simply want to know of any store that sells any of the widgets.

public List<Map<String,Object>> getStoresByWidgets(List<String> widgetNameList) {
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
    Map<String, Object> parameterMap = new HashMap<String, Object>();
    parameterMap.put("widgetNames", widgetNameList);
    String sql =
            "SELECT store_id \n" +
            "  FROM widget_store_vw wsv \n" +
            " WHERE store_status = 'Active' \n" +
            "   AND widget_name in (:widgetNames) ";
    return namedParameterJdbcTemplate.queryForList(sql, parameterMap);
}

{ 1 comment }

JPQL Syntax: joins are on the class member

June 14, 2010 Java

In JPQL, if you want to join 2 or more tables explicitly, and not simply walk the relationships in your select or where clauses, you must list the class member of the second+ tables, not the the Object. I realize the above query could be written as ” from Keywords” but we needed to filter […]

Read the full article →

Stack Trace Visibility via JNDI lookup

June 7, 2010 Java

We use a JNDI lookup to control whether a stack trace is visible. This allows us to have the stack trace visible in our development and test environments, but not in production. We have have maven deploy the correct catalina.properties according to your environment (which is outside the scope of this post). For example, in […]

Read the full article →