dgraham     2003/11/11 17:00:55

  Modified:    dbutils/src/java/org/apache/commons/dbutils QueryRunner.java
  Log:
  Fixed message created in rethrow() so it's more consistent.
  
  Revision  Changes    Path
  1.6       +18 -16    
jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java
  
  Index: QueryRunner.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- QueryRunner.java  11 Nov 2003 03:24:27 -0000      1.5
  +++ QueryRunner.java  12 Nov 2003 01:00:55 -0000      1.6
  @@ -275,16 +275,12 @@
   
           Connection conn = this.ds.getConnection();
   
  -        Object result = null;
  -
           try {
  -            result = this.query(conn, sql, params, rsh);
  +            return this.query(conn, sql, params, rsh);
   
           } finally {
               DbUtils.close(conn);
           }
  -
  -        return result;
       }
   
       /**
  @@ -310,6 +306,7 @@
        * exception when it's rethrown. 
        * 
        * @param sql The query that was executing when the exception happened.
  +     * 
        * @param params The query replacement paramaters; <code>null</code> is a 
        * valid value to pass in.
        * 
  @@ -318,17 +315,22 @@
       protected void rethrow(SQLException cause, String sql, Object[] params)
           throws SQLException {
   
  -        StringBuffer msg =
  -            new StringBuffer(cause.getMessage() + " in query " + sql);
  -            
  -        if (params != null) {
  -            msg.append(Arrays.asList(params).toString());
  +        StringBuffer msg = new StringBuffer(cause.getMessage());
  +
  +        msg.append(" Query: ");
  +        msg.append(sql);
  +        msg.append(" Parameters: ");
  +
  +        if (params == null) {
  +            msg.append("[]");
  +        } else {
  +            msg.append(Arrays.asList(params));
           }
   
  -        SQLException newsqle = new SQLException(msg.toString());
  -        newsqle.setNextException(cause);
  +        SQLException e = new SQLException(msg.toString());
  +        e.setNextException(cause);
   
  -        throw newsqle;
  +        throw e;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to