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]update with results
Date Fri, 28 Feb 2003 15:17:52 GMT
Hey guys,

Wouldn't it be helpful to add an update which returns results?

Something like:

    public static int executeUpdate(Connection connection, String query, 
                                        Object[] vals,
                                        ResultSetHandler rsh
                                       ) throws SQLException 
    {
        PreparedStatement stmt = null;

        stmt = connection.prepareStatement(query);
        fillStatement(stmt, vals);
        try {
            if (stmt.executeUpdate())
            {
                stmt.getMoreResults();
                return rsh.handle(stmt.getResultSet());
            }
            return false;
       } catch(SQLException sqle) {
            String msg = sqle.getMessage() + " in query " + query + 
                java.util.Arrays.asList(vals).toString();
            SQLException newsqle = new SQLException(msg);
            newsqle.setNextException(sqle);
            throw newsqle;
        } finally {
            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