commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, James H [IT]" <james.h.ander...@citigroup.com>
Subject [DBUtils] SqlNullCheckedResultSet not replacing nulls
Date Wed, 21 Apr 2004 12:23:18 GMT
In the following code snippet, SqlNullCheckedResultSet is not replacing nulls, neither for
String nor Date results.

Anyone have an idea what's wrong?

Thanks,

jim

        [...]

        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conn = DriverManager.getConnection(url, user, pswd);
 
            MapListHandler mlh = new MapListHandler() {
                    public Object handle (ResultSet rs) {
                        SqlNullCheckedResultSet wrapper = new SqlNullCheckedResultSet(rs);
                        wrapper.setNullString("--n/a--");
                        wrapper.setNullDate(today);
                        rs = ProxyFactory.instance().createResultSet(wrapper);
                        Object returnVal = null;
                        try {
                            System.out.println("*** HERE ***");
                            returnVal = super.handle(rs);
                        } catch (Exception e) {
                            System.out.println(e.getMessage());
                        }
                        return returnVal;
                    }
                };

            QueryRunner run = new QueryRunner();
            List result = (List) run.query(conn, query, mlh);
            Iterator it1 = result.iterator();
            while (it1.hasNext()) {
                Map map = (Map) it1.next();
                Set keys = map.keySet();
                Iterator it = keys.iterator();
                while (it.hasNext()) {
                    String key = (String) it.next();
                    System.out.println(key + ": " + map.get(key));
                }
                System.out.println();
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        } finally {
            org.apache.commons.dbutils.DbUtils.commitAndCloseQuietly(conn);
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message