commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From george stewart <gstew...@us-south.net>
Subject [dbutils] public access to ResultSetHandler
Date Fri, 21 Feb 2003 14:52:57 GMT
Hi,

Could the developers elaborate on reasons for having package access to the interface ResultSetHandler?

If this was public, user's could create objects without using the object arrays. 
If it ever becomes public, it would be nice to have something like this in the package:


    static void executeQuery(Connection connection, String query, 
                               Object[] vals, ResultSetHandler rsh,
                               Collection cln
                               ) throws SQLException 
    {
    
        PreparedStatement stmt = null;
        ResultSet rs = null;

        try {
                
            stmt = connection.prepareStatement(query);
            fillStatement(stmt, vals);
            
            try{
                rs = stmt.executeQuery();
                while (rs.next()) {
                    cln.add(rsh.handle(rs));
                }
              
            }catch(SQLException sqle){
                String msg = sqle.getMessage() + " in query " + query + 
                    java.util.Arrays.asList(vals).toString();
                SQLException e = new SQLException(msg);
                e.setNextException(sqle);
                throw e;
            }
            
        } finally {
            closeQuietly(rs);
            closeQuietly(stmt);
        }
    
    }


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


Mime
View raw message