commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils ResultSetHandler.java ProxyFactory.java DbUtils.java QueryRunner.java
Date Fri, 24 Oct 2003 04:25:25 GMT
dgraham     2003/10/23 21:25:25

  Modified:    dbutils/src/java/org/apache/commons/dbutils/handlers
                        MapHandler.java BeanListHandler.java
                        BeanHandler.java MapListHandler.java
                        ScalarHandler.java ArrayListHandler.java
                        ArrayHandler.java
               dbutils/src/java/org/apache/commons/dbutils
                        ResultSetHandler.java ProxyFactory.java
                        DbUtils.java QueryRunner.java
  Log:
  Removed tabs.
  
  Revision  Changes    Path
  1.4       +42 -42    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/MapHandler.java
  
  Index: MapHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/MapHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MapHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ MapHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -79,44 +79,44 @@
    */
   public class MapHandler implements ResultSetHandler {
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into Maps.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into Maps.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
   
  -	/** 
  -	 * Creates a new instance of MapHandler using a 
  -	 * <code>BasicRowProcessor</code> for conversion.
  -	 */
  -	public MapHandler() {
  -		super();
  -	}
  +    /** 
  +     * Creates a new instance of MapHandler using a 
  +     * <code>BasicRowProcessor</code> for conversion.
  +     */
  +    public MapHandler() {
  +        super();
  +    }
   
  -	/** 
  -	 * Creates a new instance of MapHandler.
  -	 * 
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into Maps.
  -	 */
  -	public MapHandler(RowProcessor convert) {
  -		super();
  -		this.convert = convert;
  -	}
  +    /** 
  +     * Creates a new instance of MapHandler.
  +     * 
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into Maps.
  +     */
  +    public MapHandler(RowProcessor convert) {
  +        super();
  +        this.convert = convert;
  +    }
   
  -	/**
  -	 * Converts the first row in the <code>ResultSet</code> into a 
  -	 * <code>Map</code>.
  -	 * 
  -	 * @return A <code>Map</code> with the values from the first row or 
  -	 * <code>null</code> if there are no rows in the <code>ResultSet</code>. 
  -	 * 
  -	 * @throws SQLException
  -	 * 
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -		return rs.next() ? this.convert.toMap(rs) : null;
  -	}
  +    /**
  +     * Converts the first row in the <code>ResultSet</code> into a 
  +     * <code>Map</code>.
  +     * 
  +     * @return A <code>Map</code> with the values from the first row or 
  +     * <code>null</code> if there are no rows in the <code>ResultSet</code>. 
  +     * 
  +     * @throws SQLException
  +     * 
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +        return rs.next() ? this.convert.toMap(rs) : null;
  +    }
   
   }
  
  
  
  1.4       +50 -50    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/BeanListHandler.java
  
  Index: BeanListHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/BeanListHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BeanListHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ BeanListHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -80,52 +80,52 @@
    */
   public class BeanListHandler implements ResultSetHandler {
   
  -	/**
  -	 * The Class of beans produced by this handler.
  -	 */
  -	private Class type = null;
  +    /**
  +     * The Class of beans produced by this handler.
  +     */
  +    private Class type = null;
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into beans.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into beans.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
   
  -	/** 
  -	 * Creates a new instance of BeanListHandler.
  -	 * 
  -	 * @param type The Class that objects returned from <code>handle()</code>
  -	 * are created from.
  -	 */
  -	public BeanListHandler(Class type) {
  -		this.type = type;
  -	}
  +    /** 
  +     * Creates a new instance of BeanListHandler.
  +     * 
  +     * @param type The Class that objects returned from <code>handle()</code>
  +     * are created from.
  +     */
  +    public BeanListHandler(Class type) {
  +        this.type = type;
  +    }
   
  -	/** 
  -	 * Creates a new instance of BeanListHandler.
  -	 * 
  -	 * @param type The Class that objects returned from <code>handle()</code>
  -	 * are created from.
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into beans.
  -	 */
  -	public BeanListHandler(Class type, RowProcessor convert) {
  -		this.type = type;
  -		this.convert = convert;
  -	}
  +    /** 
  +     * Creates a new instance of BeanListHandler.
  +     * 
  +     * @param type The Class that objects returned from <code>handle()</code>
  +     * are created from.
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into beans.
  +     */
  +    public BeanListHandler(Class type, RowProcessor convert) {
  +        this.type = type;
  +        this.convert = convert;
  +    }
   
  -	/**
  -	 * Convert the <code>ResultSet</code> rows into a <code>List</code> of 
  -	 * beans with the <code>Class</code> given in the constructor.
  -	 * 
  -	 * @return A <code>List</code> of beans (one for each row), never 
  -	 * <code>null</code>.
  -	 * 
  -	 * @throws SQLException
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -		return this.convert.toBeanList(rs, type);
  -	}
  +    /**
  +     * Convert the <code>ResultSet</code> rows into a <code>List</code> of 
  +     * beans with the <code>Class</code> given in the constructor.
  +     * 
  +     * @return A <code>List</code> of beans (one for each row), never 
  +     * <code>null</code>.
  +     * 
  +     * @throws SQLException
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +        return this.convert.toBeanList(rs, type);
  +    }
   
   }
  
  
  
  1.4       +50 -50    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/BeanHandler.java
  
  Index: BeanHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/BeanHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BeanHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ BeanHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -78,52 +78,52 @@
    */
   public class BeanHandler implements ResultSetHandler {
   
  -	/**
  -	 * The Class of beans produced by this handler.
  -	 */
  -	private Class type = null;
  +    /**
  +     * The Class of beans produced by this handler.
  +     */
  +    private Class type = null;
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into beans.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into beans.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
   
  -	/** 
  -	 * Creates a new instance of BeanHandler.
  -	 * 
  -	 * @param type The Class that objects returned from <code>handle()</code>
  -	 * are created from.
  -	 */
  -	public BeanHandler(Class type) {
  -		this.type = type;
  -	}
  +    /** 
  +     * Creates a new instance of BeanHandler.
  +     * 
  +     * @param type The Class that objects returned from <code>handle()</code>
  +     * are created from.
  +     */
  +    public BeanHandler(Class type) {
  +        this.type = type;
  +    }
   
  -	/** 
  -	 * Creates a new instance of BeanHandler.
  -	 * 
  -	 * @param type The Class that objects returned from <code>handle()</code>
  -	 * are created from.
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into beans.
  -	 */
  -	public BeanHandler(Class type, RowProcessor convert) {
  -		this.type = type;
  -		this.convert = convert;
  -	}
  +    /** 
  +     * Creates a new instance of BeanHandler.
  +     * 
  +     * @param type The Class that objects returned from <code>handle()</code>
  +     * are created from.
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into beans.
  +     */
  +    public BeanHandler(Class type, RowProcessor convert) {
  +        this.type = type;
  +        this.convert = convert;
  +    }
   
  -	/**
  -	 * Convert the first row of the <code>ResultSet</code> into a bean with the
  -	 * <code>Class</code> given in the constructor.
  -	 * 
  -	 * @return An initialized JavaBean or <code>null</code> if there were no 
  -	 * rows in the <code>ResultSet</code>.
  -	 * 
  -	 * @throws SQLException
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -		return rs.next() ? this.convert.toBean(rs, this.type) : null;
  -	}
  +    /**
  +     * Convert the first row of the <code>ResultSet</code> into a bean with the
  +     * <code>Class</code> given in the constructor.
  +     * 
  +     * @return An initialized JavaBean or <code>null</code> if there were no 
  +     * rows in the <code>ResultSet</code>.
  +     * 
  +     * @throws SQLException
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +        return rs.next() ? this.convert.toBean(rs, this.type) : null;
  +    }
   
   }
  
  
  
  1.4       +47 -47    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/MapListHandler.java
  
  Index: MapListHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/MapListHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MapListHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ MapListHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -81,50 +81,50 @@
    */
   public class MapListHandler implements ResultSetHandler {
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into Maps.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  -
  -	/** 
  -	 * Creates a new instance of MapListHandler using a 
  -	 * <code>BasicRowProcessor</code> for conversion.
  -	 */
  -	public MapListHandler() {
  -		super();
  -	}
  -
  -	/** 
  -	 * Creates a new instance of MapListHandler.
  -	 * 
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into Maps.
  -	 */
  -	public MapListHandler(RowProcessor convert) {
  -		super();
  -		this.convert = convert;
  -	}
  -
  -	/**
  -	 * Converts the <code>ResultSet</code> rows into a <code>List</code> of 
  -	 * <code>Map</code> objects.
  -	 * 
  -	 * @return A <code>List</code> of <code>Map</code>s, never null.  
  -	 * 
  -	 * @throws SQLException
  -	 * 
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -
  -		List results = new ArrayList();
  -
  -		while (rs.next()) {
  -			results.add(this.convert.toMap(rs));
  -		}
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into Maps.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
  +
  +    /** 
  +     * Creates a new instance of MapListHandler using a 
  +     * <code>BasicRowProcessor</code> for conversion.
  +     */
  +    public MapListHandler() {
  +        super();
  +    }
  +
  +    /** 
  +     * Creates a new instance of MapListHandler.
  +     * 
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into Maps.
  +     */
  +    public MapListHandler(RowProcessor convert) {
  +        super();
  +        this.convert = convert;
  +    }
  +
  +    /**
  +     * Converts the <code>ResultSet</code> rows into a <code>List</code> of 
  +     * <code>Map</code> objects.
  +     * 
  +     * @return A <code>List</code> of <code>Map</code>s, never null.  
  +     * 
  +     * @throws SQLException
  +     * 
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +
  +        List results = new ArrayList();
  +
  +        while (rs.next()) {
  +            results.add(this.convert.toMap(rs));
  +        }
   
  -		return results;
  -	}
  +        return results;
  +    }
   
   }
  
  
  
  1.4       +67 -67    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ScalarHandler.java
  
  Index: ScalarHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ScalarHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScalarHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ ScalarHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -76,68 +76,68 @@
    */
   public class ScalarHandler implements ResultSetHandler {
   
  -	/**
  -	 * The column number to retrieve.
  -	 */
  -	private int columnIndex = 1;
  -
  -	/**
  -	 * The column name to retrieve.  Either columnName or columnIndex
  -	 * will be used but never both.
  -	 */
  -	private String columnName = null;
  -
  -	/** 
  -	 * Creates a new instance of ScalarHandler.  The first column will
  -	 * be returned from <code>handle()</code>.
  -	 */
  -	public ScalarHandler() {
  -		super();
  -	}
  -
  -	/** 
  -	 * Creates a new instance of ScalarHandler.
  -	 * 
  -	 * @param columnIndex The index of the column to retrieve from the 
  -	 * <code>ResultSet</code>.
  -	 */
  -	public ScalarHandler(int columnIndex) {
  -		this.columnIndex = columnIndex;
  -	}
  -
  -	/** 
  -	 * Creates a new instance of ScalarHandler.
  -	 * 
  -	 * @param columnName The name of the column to retrieve from the 
  -	 * <code>ResultSet</code>.
  -	 */
  -	public ScalarHandler(String columnName) {
  -		this.columnName = columnName;
  -	}
  -
  -	/**
  -	 * Returns one <code>ResultSet</code> column as an object via the
  -	 * <code>ResultSet.getObject()</code> method that performs type 
  -	 * conversions.
  -	 * 
  -	 * @return The column or <code>null</code> if there are no rows in
  -	 * the <code>ResultSet</code>.
  -	 * 
  -	 * @throws SQLException
  -	 * 
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -
  -		if (rs.next()) {
  -			if (this.columnName == null) {
  -				return rs.getObject(this.columnIndex);
  -			} else {
  -				return rs.getObject(this.columnName);
  -			}
  -
  -		} else {
  -			return null;
  -		}
  -	}
  +    /**
  +     * The column number to retrieve.
  +     */
  +    private int columnIndex = 1;
  +
  +    /**
  +     * The column name to retrieve.  Either columnName or columnIndex
  +     * will be used but never both.
  +     */
  +    private String columnName = null;
  +
  +    /** 
  +     * Creates a new instance of ScalarHandler.  The first column will
  +     * be returned from <code>handle()</code>.
  +     */
  +    public ScalarHandler() {
  +        super();
  +    }
  +
  +    /** 
  +     * Creates a new instance of ScalarHandler.
  +     * 
  +     * @param columnIndex The index of the column to retrieve from the 
  +     * <code>ResultSet</code>.
  +     */
  +    public ScalarHandler(int columnIndex) {
  +        this.columnIndex = columnIndex;
  +    }
  +
  +    /** 
  +     * Creates a new instance of ScalarHandler.
  +     * 
  +     * @param columnName The name of the column to retrieve from the 
  +     * <code>ResultSet</code>.
  +     */
  +    public ScalarHandler(String columnName) {
  +        this.columnName = columnName;
  +    }
  +
  +    /**
  +     * Returns one <code>ResultSet</code> column as an object via the
  +     * <code>ResultSet.getObject()</code> method that performs type 
  +     * conversions.
  +     * 
  +     * @return The column or <code>null</code> if there are no rows in
  +     * the <code>ResultSet</code>.
  +     * 
  +     * @throws SQLException
  +     * 
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +
  +        if (rs.next()) {
  +            if (this.columnName == null) {
  +                return rs.getObject(this.columnIndex);
  +            } else {
  +                return rs.getObject(this.columnName);
  +            }
  +
  +        } else {
  +            return null;
  +        }
  +    }
   }
  
  
  
  1.4       +48 -48    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java
  
  Index: ArrayListHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ArrayListHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayListHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ ArrayListHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -82,51 +82,51 @@
    */
   public class ArrayListHandler implements ResultSetHandler {
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into Object[]s.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  -
  -	/** 
  -	 * Creates a new instance of ArrayListHandler using a 
  -	 * <code>BasicRowProcessor</code> for conversions.
  -	 */
  -	public ArrayListHandler() {
  -		super();
  -	}
  -
  -	/** 
  -	 * Creates a new instance of ArrayListHandler.
  -	 * 
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into Object[]s.
  -	 */
  -	public ArrayListHandler(RowProcessor convert) {
  -		super();
  -		this.convert = convert;
  -	}
  -
  -	/**
  -	 * Convert each row's columns into an <code>Object[]</code> and store them 
  -	 * in a <code>List</code> in the same order they are returned from the
  -	 * <code>ResultSet.next()</code> method. 
  -	 * 
  -	 * @return A <code>List</code> of <code>Object[]</code>s, never 
  -	 * <code>null</code>.
  -	 * 
  -	 * @throws SQLException
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -
  -		List result = new ArrayList();
  -
  -		while (rs.next()) {
  -			result.add(this.convert.toArray(rs));
  -		}
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into Object[]s.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
  +
  +    /** 
  +     * Creates a new instance of ArrayListHandler using a 
  +     * <code>BasicRowProcessor</code> for conversions.
  +     */
  +    public ArrayListHandler() {
  +        super();
  +    }
  +
  +    /** 
  +     * Creates a new instance of ArrayListHandler.
  +     * 
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into Object[]s.
  +     */
  +    public ArrayListHandler(RowProcessor convert) {
  +        super();
  +        this.convert = convert;
  +    }
  +
  +    /**
  +     * Convert each row's columns into an <code>Object[]</code> and store them 
  +     * in a <code>List</code> in the same order they are returned from the
  +     * <code>ResultSet.next()</code> method. 
  +     * 
  +     * @return A <code>List</code> of <code>Object[]</code>s, never 
  +     * <code>null</code>.
  +     * 
  +     * @throws SQLException
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +
  +        List result = new ArrayList();
  +
  +        while (rs.next()) {
  +            result.add(this.convert.toArray(rs));
  +        }
   
  -		return result;
  -	}
  +        return result;
  +    }
   
   }
  
  
  
  1.4       +40 -40    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ArrayHandler.java
  
  Index: ArrayHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/handlers/ArrayHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArrayHandler.java	24 Oct 2003 04:01:52 -0000	1.3
  +++ ArrayHandler.java	24 Oct 2003 04:25:24 -0000	1.4
  @@ -80,42 +80,42 @@
    */
   public class ArrayHandler implements ResultSetHandler {
   
  -	/**
  -	 * The RowProcessor implementation to use when converting rows 
  -	 * into arrays.
  -	 */
  -	private RowProcessor convert = BasicRowProcessor.instance();
  +    /**
  +     * The RowProcessor implementation to use when converting rows 
  +     * into arrays.
  +     */
  +    private RowProcessor convert = BasicRowProcessor.instance();
   
  -	/** 
  -	 * Creates a new instance of ArrayHandler using a 
  -	 * <code>BasicRowProcessor</code> for conversion.
  -	 */
  -	public ArrayHandler() {
  -		super();
  -	}
  +    /** 
  +     * Creates a new instance of ArrayHandler using a 
  +     * <code>BasicRowProcessor</code> for conversion.
  +     */
  +    public ArrayHandler() {
  +        super();
  +    }
   
  -	/** 
  -	 * Creates a new instance of ArrayHandler.
  -	 * 
  -	 * @param convert The <code>RowProcessor</code> implementation 
  -	 * to use when converting rows into arrays.
  -	 */
  -	public ArrayHandler(RowProcessor convert) {
  -		super();
  -		this.convert = convert;
  -	}
  +    /** 
  +     * Creates a new instance of ArrayHandler.
  +     * 
  +     * @param convert The <code>RowProcessor</code> implementation 
  +     * to use when converting rows into arrays.
  +     */
  +    public ArrayHandler(RowProcessor convert) {
  +        super();
  +        this.convert = convert;
  +    }
   
  -	/**
  -	 * Places the column values from the first row in an <code>Object[]</code>.
  -	 * 
  -	 * @return An Object[] or <code>null</code> if there are no rows in the
  -	 * <code>ResultSet</code>.
  -	 * 
  -	 * @throws SQLException
  -	 * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException {
  -		return rs.next() ? this.convert.toArray(rs) : null;
  -	}
  +    /**
  +     * Places the column values from the first row in an <code>Object[]</code>.
  +     * 
  +     * @return An Object[] or <code>null</code> if there are no rows in the
  +     * <code>ResultSet</code>.
  +     * 
  +     * @throws SQLException
  +     * @see org.apache.commons.dbutils.ResultSetHandler#handle(java.sql.ResultSet)
  +     */
  +    public Object handle(ResultSet rs) throws SQLException {
  +        return rs.next() ? this.convert.toArray(rs) : null;
  +    }
   
   }
  
  
  
  1.7       +16 -16    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ResultSetHandler.java
  
  Index: ResultSetHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ResultSetHandler.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ResultSetHandler.java	22 Oct 2003 23:33:25 -0000	1.6
  +++ ResultSetHandler.java	24 Oct 2003 04:25:25 -0000	1.7
  @@ -72,18 +72,18 @@
    */
   public interface ResultSetHandler {
   
  -	/**
  -	 * Turn the <code>ResultSet</code> into an Object.
  -	 * 
  -	 * @param rs The <code>ResultSet</code> to handle.  It has not been touched
  -	 * before being passed to this method.
  -	 * 
  -	 * @return An Object initialized with <code>ResultSet</code> data. It is
  -	 * legal for implementations to return <code>null</code> if the 
  -	 * <code>ResultSet</code> contained 0 rows.
  -	 * 
  -	 * @throws SQLException
  -	 */
  -	public Object handle(ResultSet rs) throws SQLException;
  +    /**
  +     * Turn the <code>ResultSet</code> into an Object.
  +     * 
  +     * @param rs The <code>ResultSet</code> to handle.  It has not been touched
  +     * before being passed to this method.
  +     * 
  +     * @return An Object initialized with <code>ResultSet</code> data. It is
  +     * legal for implementations to return <code>null</code> if the 
  +     * <code>ResultSet</code> contained 0 rows.
  +     * 
  +     * @throws SQLException
  +     */
  +    public Object handle(ResultSet rs) throws SQLException;
   
   }
  
  
  
  1.5       +139 -139  jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProxyFactory.java
  
  Index: ProxyFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/ProxyFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProxyFactory.java	24 Oct 2003 04:01:52 -0000	1.4
  +++ ProxyFactory.java	24 Oct 2003 04:25:25 -0000	1.5
  @@ -83,141 +83,141 @@
    */
   public class ProxyFactory {
   
  -	/**
  -	 * Class[] for CallableStatement interface.
  -	 */
  -	private static final Class[] callableStatementClass =
  -		new Class[] { CallableStatement.class };
  -
  -	/**
  -	 * Class[] for Connection interface.
  -	 */
  -	private static final Class[] connectionClass =
  -		new Class[] { Connection.class };
  -
  -	/**
  -	 * Class[] for Driver interface.
  -	 */
  -	private static final Class[] driverClass = new Class[] { Driver.class };
  -
  -	/**
  -	 * The Singleton instance of this class.
  -	 */
  -	private static final ProxyFactory instance = new ProxyFactory();
  -
  -	/**
  -	 * Class[] for ResultSetMetaData interface.
  -	 */
  -	private static final Class[] metaClass =
  -		new Class[] { ResultSetMetaData.class };
  -
  -	/**
  -	 * Class[] for PreparedStatement interface.
  -	 */
  -	private static final Class[] preparedStatementClass =
  -		new Class[] { PreparedStatement.class };
  -
  -	/**
  -	 * Class[] for ResultSet interface.
  -	 */
  -	private static final Class[] resultSetClass =
  -		new Class[] { ResultSet.class };
  -
  -	/**
  -	 * Class[] for Statement interface.
  -	 */
  -	private static final Class[] statementClass =
  -		new Class[] { Statement.class };
  -
  -	/**
  -	 * Returns the Singleton instance of this class.
  -	 */
  -	public static ProxyFactory instance() {
  -		return instance;
  -	}
  -
  -	/**
  -	 * Protected constructor for ProxyFactory subclasses to use.
  -	 */
  -	protected ProxyFactory() {
  -		super();
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>CallableStatement</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public PreparedStatement createCallableStatement(InvocationHandler handler) {
  -		return (CallableStatement) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			callableStatementClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>Connection</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public Connection createConnection(InvocationHandler handler) {
  -		return (Connection) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			connectionClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>Driver</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public Driver createDriver(InvocationHandler handler) {
  -		return (Driver) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			driverClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>PreparedStatement</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public PreparedStatement createPreparedStatement(InvocationHandler handler) {
  -		return (PreparedStatement) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			preparedStatementClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>ResultSet</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public ResultSet createResultSet(InvocationHandler handler) {
  -		return (ResultSet) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			resultSetClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>ResultSetMetaData</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public ResultSetMetaData createResultSetMetaData(InvocationHandler handler) {
  -		return (ResultSetMetaData) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			metaClass,
  -			handler);
  -	}
  -
  -	/**
  -	 * Creates a new proxy <code>Statement</code> object.
  -	 * @param handler The handler that intercepts/overrides method calls.
  -	 */
  -	public Statement createStatement(InvocationHandler handler) {
  -		return (Statement) Proxy.newProxyInstance(
  -			handler.getClass().getClassLoader(),
  -			statementClass,
  -			handler);
  -	}
  +    /**
  +     * Class[] for CallableStatement interface.
  +     */
  +    private static final Class[] callableStatementClass =
  +        new Class[] { CallableStatement.class };
  +
  +    /**
  +     * Class[] for Connection interface.
  +     */
  +    private static final Class[] connectionClass =
  +        new Class[] { Connection.class };
  +
  +    /**
  +     * Class[] for Driver interface.
  +     */
  +    private static final Class[] driverClass = new Class[] { Driver.class };
  +
  +    /**
  +     * The Singleton instance of this class.
  +     */
  +    private static final ProxyFactory instance = new ProxyFactory();
  +
  +    /**
  +     * Class[] for ResultSetMetaData interface.
  +     */
  +    private static final Class[] metaClass =
  +        new Class[] { ResultSetMetaData.class };
  +
  +    /**
  +     * Class[] for PreparedStatement interface.
  +     */
  +    private static final Class[] preparedStatementClass =
  +        new Class[] { PreparedStatement.class };
  +
  +    /**
  +     * Class[] for ResultSet interface.
  +     */
  +    private static final Class[] resultSetClass =
  +        new Class[] { ResultSet.class };
  +
  +    /**
  +     * Class[] for Statement interface.
  +     */
  +    private static final Class[] statementClass =
  +        new Class[] { Statement.class };
  +
  +    /**
  +     * Returns the Singleton instance of this class.
  +     */
  +    public static ProxyFactory instance() {
  +        return instance;
  +    }
  +
  +    /**
  +     * Protected constructor for ProxyFactory subclasses to use.
  +     */
  +    protected ProxyFactory() {
  +        super();
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>CallableStatement</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public PreparedStatement createCallableStatement(InvocationHandler handler) {
  +        return (CallableStatement) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            callableStatementClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>Connection</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public Connection createConnection(InvocationHandler handler) {
  +        return (Connection) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            connectionClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>Driver</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public Driver createDriver(InvocationHandler handler) {
  +        return (Driver) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            driverClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>PreparedStatement</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public PreparedStatement createPreparedStatement(InvocationHandler handler) {
  +        return (PreparedStatement) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            preparedStatementClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>ResultSet</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public ResultSet createResultSet(InvocationHandler handler) {
  +        return (ResultSet) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            resultSetClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>ResultSetMetaData</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public ResultSetMetaData createResultSetMetaData(InvocationHandler handler) {
  +        return (ResultSetMetaData) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            metaClass,
  +            handler);
  +    }
  +
  +    /**
  +     * Creates a new proxy <code>Statement</code> object.
  +     * @param handler The handler that intercepts/overrides method calls.
  +     */
  +    public Statement createStatement(InvocationHandler handler) {
  +        return (Statement) Proxy.newProxyInstance(
  +            handler.getClass().getClassLoader(),
  +            statementClass,
  +            handler);
  +    }
   
   }
  
  
  
  1.42      +48 -45    jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java
  
  Index: DbUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- DbUtils.java	24 Oct 2003 04:01:52 -0000	1.41
  +++ DbUtils.java	24 Oct 2003 04:25:25 -0000	1.42
  @@ -58,7 +58,7 @@
    * <http://www.apache.org/>.
    *
    */
  - 
  +
   package org.apache.commons.dbutils;
   
   import java.io.PrintWriter;
  @@ -76,7 +76,7 @@
    * @author David Graham
    */
   public final class DbUtils {
  -       
  +
       /**
        * Close a <code>Connection</code>, avoid closing if null.
        */
  @@ -85,7 +85,7 @@
               conn.close();
           }
       }
  -    
  +
       /**
        * Close a <code>ResultSet</code>, avoid closing if null.
        */
  @@ -103,7 +103,7 @@
               stmt.close();
           }
       }
  -    
  +
       /**
        * Close a <code>Connection</code>, avoid closing if null and hide
        * any exceptions that occur.
  @@ -115,18 +115,21 @@
               // quiet
           }
       }
  -    
  +
       /**
        * Close a <code>Connection</code>, <code>Statement</code> and 
        * <code>ResultSet</code>.  Avoid closing if null and hide any 
        * exceptions that occur.
        */
  -    public static void closeQuietly(Connection conn, Statement stmt, ResultSet rs) {
  +    public static void closeQuietly(
  +        Connection conn,
  +        Statement stmt,
  +        ResultSet rs) {
           closeQuietly(rs);
           closeQuietly(stmt);
           closeQuietly(conn);
       }
  -    
  +
       /**
        * Close a <code>ResultSet</code>, avoid closing if null and hide
        * any exceptions that occur.
  @@ -138,7 +141,7 @@
               // quiet
           }
       }
  -    
  +
       /**
        * Close a <code>Statement</code>, avoid closing if null and hide
        * any exceptions that occur.
  @@ -150,7 +153,7 @@
               // quiet
           }
       }
  -    
  +
       /**
        * Commits a <code>Connection</code> then closes it, avoid closing if null.
        */
  @@ -160,7 +163,7 @@
               conn.close();
           }
       }
  -    
  +
       /**
        * Commits a <code>Connection</code> then closes it, avoid closing if null 
        * and hide any exceptions that occur.
  @@ -172,38 +175,38 @@
               // quiet
           }
       }
  -    
  +
       /**
        * Loads and registers a database driver class.
        * If this succeeds, it returns true, else it returns false.
        */
  -	public static boolean loadDriver(String driverClassName) {
  -		try {
  -			Class.forName(driverClassName).newInstance();
  -			return true;
  -
  -		} catch (ClassNotFoundException e) {
  -			// TODO Logging?
  -			//e.printStackTrace();
  -			return false;
  -
  -		} catch (IllegalAccessException e) {
  -			// TODO Logging?
  -			//e.printStackTrace();
  -
  -			// Constructor is private, OK for DriverManager contract
  -			return true;
  -
  -		} catch (InstantiationException e) {
  -			// TODO Logging?
  -			//e.printStackTrace();
  -			return false;
  -
  -		} catch (Throwable t) {
  -			return false;
  -		}
  -	}
  -    
  +    public static boolean loadDriver(String driverClassName) {
  +        try {
  +            Class.forName(driverClassName).newInstance();
  +            return true;
  +
  +        } catch (ClassNotFoundException e) {
  +            // TODO Logging?
  +            //e.printStackTrace();
  +            return false;
  +
  +        } catch (IllegalAccessException e) {
  +            // TODO Logging?
  +            //e.printStackTrace();
  +
  +            // Constructor is private, OK for DriverManager contract
  +            return true;
  +
  +        } catch (InstantiationException e) {
  +            // TODO Logging?
  +            //e.printStackTrace();
  +            return false;
  +
  +        } catch (Throwable t) {
  +            return false;
  +        }
  +    }
  +
       public static void printStackTrace(SQLException sqle) {
           printStackTrace(sqle, new PrintWriter(System.err));
       }
  @@ -219,11 +222,11 @@
               }
           }
       }
  -    
  +
       public static void printWarnings(Connection connection) {
           printWarnings(connection, new PrintWriter(System.err));
       }
  -    
  +
       public static void printWarnings(Connection conn, PrintWriter pw) {
           if (conn != null) {
               try {
  @@ -233,7 +236,7 @@
               }
           }
       }
  -    
  +
       /**
        * Rollback any changes made on the given connection.
        * @param conn The database Connection to rollback.  A null value is legal.
  @@ -244,5 +247,5 @@
               conn.rollback();
           }
       }
  -    
  +
   }
  
  
  
  1.12      +391 -391  jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java
  
  Index: QueryRunner.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/QueryRunner.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- QueryRunner.java	24 Oct 2003 04:10:21 -0000	1.11
  +++ QueryRunner.java	24 Oct 2003 04:25:25 -0000	1.12
  @@ -83,393 +83,393 @@
    */
   public class QueryRunner {
   
  -	/**
  -	 * The DataSource to retrieve connections from.
  -	 */
  -	protected DataSource ds = null;
  -
  -	/**
  -	 * Constructor for QueryRunner.
  -	 */
  -	public QueryRunner() {
  -		super();
  -	}
  -
  -	/**
  -	 * Constructor for QueryRunner.  Methods that do not take a 
  -	 * <code>Connection</code> parameter will retrieve connections from this
  -	 * <code>DataSource</code>.
  -	 * 
  -	 * @param ds The <code>DataSource</code> to retrieve connections from.
  -	 */
  -	public QueryRunner(DataSource ds) {
  -		super();
  -		this.ds = ds;
  -	}
  -
  -	/**
  -	 * Fill the <code>PreparedStatement</code> replacement parameters with 
  -	 * the given objects.
  -	 * @param stmt
  -	 * @param params Query replacement parameters; <code>null</code> is a valid
  -	 * value to pass in.
  -	 * @throws SQLException
  -	 */
  -	protected void fillStatement(PreparedStatement stmt, Object[] params)
  -		throws SQLException {
  -
  -		if (params == null) {
  -			return;
  -		}
  -
  -		for (int i = 0; i < params.length; i++) {
  -			if (params[i] != null) {
  -				stmt.setObject(i + 1, params[i]);
  -			} else {
  -				stmt.setNull(i + 1, Types.OTHER);
  -			}
  -		}
  -	}
  -
  -	/**
  -	 * Returns the <code>DataSource</code> this runner is using.
  -	 */
  -	public DataSource getDataSource() {
  -		return this.ds;
  -	}
  -
  -	/**
  -	 * Execute an SQL SELECT query with a single replacement parameter.  The
  -	 * caller is responsible for connection cleanup.
  -	 * 
  -	 * @param conn The connection to execute the query in.
  -	 * @param sql The query to execute.
  -	 * @param param The replacement parameter.
  -	 * @param rsh The handler that converts the results into an object.
  -	 * @return The object returned by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(
  -		Connection conn,
  -		String sql,
  -		Object param,
  -		ResultSetHandler rsh)
  -		throws SQLException {
  -
  -		return this.query(conn, sql, new Object[] { param }, rsh);
  -	}
  -
  -	/**
  -	 * Execute an SQL SELECT query with replacement parameters.  The
  -	 * caller is responsible for connection cleanup.
  -	 * 
  -	 * @param conn The connection to execute the query in.
  -	 * @param sql The query to execute.
  -	 * @param params The replacement parameters.
  -	 * @param rsh The handler that converts the results into an object.
  -	 * @return The object returned by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(
  -		Connection conn,
  -		String sql,
  -		Object[] params,
  -		ResultSetHandler rsh)
  -		throws SQLException {
  -
  -		PreparedStatement stmt = null;
  -		ResultSet rs = null;
  -		Object result = null;
  -
  -		try {
  -			stmt = conn.prepareStatement(sql);
  -			this.fillStatement(stmt, params);
  -
  -			rs = this.wrap(stmt.executeQuery());
  -
  -			result = rsh.handle(rs);
  -
  -		} catch (SQLException e) {
  -			this.rethrow(e, sql, params);
  -
  -		} finally {
  -			DbUtils.closeQuietly(rs);
  -			DbUtils.closeQuietly(stmt);
  -		}
  -
  -		return result;
  -	}
  -
  -	/**
  -	 * Execute an SQL SELECT query without any replacement parameters.  The
  -	 * caller is responsible for connection cleanup.
  -	 * 
  -	 * @param conn The connection to execute the query in.
  -	 * @param sql The query to execute.
  -	 * @param rsh The handler that converts the results into an object.
  -	 * @return The object returned by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(Connection conn, String sql, ResultSetHandler rsh)
  -		throws SQLException {
  -
  -		return this.query(conn, sql, (Object[]) null, rsh);
  -	}
  -
  -	/**
  -	 * Executes the given SELECT SQL with a single replacement parameter.
  -	 * The <code>Connection</code> is retrieved from the
  -	 * <code>DataSource</code> set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @param param The replacement parameter.
  -	 * @param rsh The handler used to create the result object from 
  -	 * the <code>ResultSet</code>.
  -	 * 
  -	 * @return An object generated by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(String sql, Object param, ResultSetHandler rsh)
  -		throws SQLException {
  -
  -		return this.query(sql, new Object[] { param }, rsh);
  -	}
  -
  -	/**
  -	 * Executes the given SELECT SQL query and returns a result object.
  -	 * The <code>Connection</code> is retrieved from the 
  -	 * <code>DataSource</code> set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @param params Initialize the PreparedStatement's IN parameters with 
  -	 * this array.
  -	 * 
  -	 * @param rsh The handler used to create the result object from 
  -	 * the <code>ResultSet</code>.
  -	 * 
  -	 * @return An object generated by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(String sql, Object[] params, ResultSetHandler rsh)
  -		throws SQLException {
  -
  -		Connection conn = this.ds.getConnection();
  -
  -		Object result = null;
  -
  -		try {
  -			result = this.query(conn, sql, params, rsh);
  -
  -		} finally {
  -			DbUtils.closeQuietly(conn);
  -		}
  -
  -		return result;
  -	}
  -
  -	/**
  -	 * Executes the given SELECT SQL without any replacement parameters.
  -	 * The <code>Connection</code> is retrieved from the
  -	 * <code>DataSource</code> set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @param rsh The handler used to create the result object from 
  -	 * the <code>ResultSet</code>.
  -	 * 
  -	 * @return An object generated by the handler.
  -	 * @throws SQLException
  -	 */
  -	public Object query(String sql, ResultSetHandler rsh) throws SQLException {
  -		return this.query(sql, (Object[]) null, rsh);
  -	}
  -
  -	/**
  -	 * Throws a new exception with a more informative error message.
  -	 * 
  -	 * @param cause The original exception that will be chained to the new 
  -	 * 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.
  -	 * 
  -	 * @throws SQLException
  -	 */
  -	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());
  -		}
  -
  -		SQLException newsqle = new SQLException(msg.toString());
  -		newsqle.setNextException(cause);
  -
  -		throw newsqle;
  -	}
  -
  -	/**
  -	 * Sets the <code>DataSource</code> this runner will use to get
  -	 * database connections from.  This should be called after creating a
  -	 * runner with the default constructor if you intend to use the
  -	 * execute methods without passing in a <code>Connection</code>.
  -	 * 
  -	 * @param dataSource The DataSource to use.
  -	 */
  -	public void setDataSource(DataSource dataSource) {
  -		this.ds = dataSource;
  -	}
  -
  -	/**
  -	 * Execute an SQL INSERT, UPDATE, or DELETE query without replacement
  -	 * parameters.
  -	 * 
  -	 * @param conn The connection to use to run the query.
  -	 * @param sql The SQL to execute.
  -	 * @return The number of rows updated.
  -	 * @throws SQLException
  -	 */
  -	public int update(Connection conn, String sql) throws SQLException {
  -		return this.update(conn, sql, (Object[]) null);
  -	}
  -
  -	/**
  -	 * Execute an SQL INSERT, UPDATE, or DELETE query with a single replacement
  -	 * parameter.
  -	 * 
  -	 * @param conn The connection to use to run the query.
  -	 * @param sql The SQL to execute.
  -	 * @param param The replacement parameter.
  -	 * @return The number of rows updated.
  -	 * @throws SQLException
  -	 */
  -	public int update(Connection conn, String sql, Object param)
  -		throws SQLException {
  -
  -		return this.update(conn, sql, new Object[] { param });
  -	}
  -
  -	/**
  -	 * Execute an SQL INSERT, UPDATE, or DELETE query.
  -	 * 
  -	 * @param conn The connection to use to run the query.
  -	 * @param sql The SQL to execute.
  -	 * @param params The query replacement parameters.
  -	 * @return The number of rows updated.
  -	 * @throws SQLException
  -	 */
  -	public int update(Connection conn, String sql, Object[] params)
  -		throws SQLException {
  -
  -		PreparedStatement stmt = null;
  -		int rows = 0;
  -
  -		try {
  -			stmt = conn.prepareStatement(sql);
  -			this.fillStatement(stmt, params);
  -
  -			rows = stmt.executeUpdate();
  -
  -		} catch (SQLException e) {
  -			this.rethrow(e, sql, params);
  -
  -		} finally {
  -			DbUtils.closeQuietly(stmt);
  -		}
  -
  -		return rows;
  -	}
  -
  -	/**
  -	 * Executes the given INSERT, UPDATE, or DELETE SQL statement without
  -	 * any replacement parameters.  The statement is executed in its own 
  -	 * transaction that will be committed or rolled back depending on any 
  -	 * SQLExceptions thrown.  The <code>Connection</code> is retrieved from the
  -	 * <code>DataSource</code> set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @throws SQLException
  -	 * @return The number of rows updated.
  -	 */
  -	public int update(String sql) throws SQLException {
  -		return this.update(sql, (Object[]) null);
  -	}
  -
  -	/**
  -	 * Executes the given INSERT, UPDATE, or DELETE SQL statement with
  -	 * a single replacement parameter.  The statement is executed in its own 
  -	 * transaction that will be committed or rolled back depending on any 
  -	 * SQLExceptions thrown.  The <code>Connection</code> is retrieved from the
  -	 * <code>DataSource</code> set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @param param The replacement parameter.
  -	 * @throws SQLException
  -	 * @return The number of rows updated.
  -	 */
  -	public int update(String sql, Object param) throws SQLException {
  -		return this.update(sql, new Object[] { param });
  -	}
  -
  -	/**
  -	 * Executes the given INSERT, UPDATE, or DELETE SQL statement.  The 
  -	 * statement is executed in its own transaction that will be committed or 
  -	 * rolled back depending on any SQLExceptions thrown.  The 
  -	 * <code>Connection</code> is retrieved from the <code>DataSource</code> 
  -	 * set in the constructor.
  -	 * 
  -	 * @param sql The SQL statement to execute.
  -	 * @param params Initializes the PreparedStatement's IN (ie. '?') 
  -	 * parameters.
  -	 * @throws SQLException
  -	 * @return The number of rows updated.
  -	 */
  -	public int update(String sql, Object[] params) throws SQLException {
  -
  -		Connection conn = this.ds.getConnection();
  -		int rows = 0;
  -
  -		try {
  -			conn.setAutoCommit(false); // single transaction.
  -			rows = this.update(conn, sql, params);
  -			conn.commit();
  -
  -		} catch (SQLException e) {
  -			DbUtils.rollback(conn);
  -			throw e;
  -
  -		} finally {
  -			DbUtils.closeQuietly(conn);
  -		}
  -
  -		return rows;
  -	}
  -
  -	/**
  -	 * Wrap the <code>ResultSet</code> in a decorator before processing it.
  -	 * This implementation returns the <code>ResultSet</code> it is given
  -	 * without any decoration.
  -	 *
  -	 * <p>
  -	 * Often, the implementation of this method can be done in an anonymous 
  -	 * inner class like this:
  -	 * </p>
  -	 * <pre> 
  -	 * QueryRunner run = new QueryRunner() {
  -	 *     protected void wrap(ResultSet rs) {
  -	 *         return StringTrimmedResultSet.wrap(rs);
  -	 *     }
  -	 * };
  -	 * </pre>
  -	 * 
  -	 * @param rs The <code>ResultSet</code> to decorate; never 
  -	 * <code>null</code>.
  -	 * @return The <code>ResultSet</code> wrapped in some decorator. 
  -	 */
  -	protected ResultSet wrap(ResultSet rs) {
  -		return rs;
  -	}
  +    /**
  +     * The DataSource to retrieve connections from.
  +     */
  +    protected DataSource ds = null;
  +
  +    /**
  +     * Constructor for QueryRunner.
  +     */
  +    public QueryRunner() {
  +        super();
  +    }
  +
  +    /**
  +     * Constructor for QueryRunner.  Methods that do not take a 
  +     * <code>Connection</code> parameter will retrieve connections from this
  +     * <code>DataSource</code>.
  +     * 
  +     * @param ds The <code>DataSource</code> to retrieve connections from.
  +     */
  +    public QueryRunner(DataSource ds) {
  +        super();
  +        this.ds = ds;
  +    }
  +
  +    /**
  +     * Fill the <code>PreparedStatement</code> replacement parameters with 
  +     * the given objects.
  +     * @param stmt
  +     * @param params Query replacement parameters; <code>null</code> is a valid
  +     * value to pass in.
  +     * @throws SQLException
  +     */
  +    protected void fillStatement(PreparedStatement stmt, Object[] params)
  +        throws SQLException {
  +
  +        if (params == null) {
  +            return;
  +        }
  +
  +        for (int i = 0; i < params.length; i++) {
  +            if (params[i] != null) {
  +                stmt.setObject(i + 1, params[i]);
  +            } else {
  +                stmt.setNull(i + 1, Types.OTHER);
  +            }
  +        }
  +    }
  +
  +    /**
  +     * Returns the <code>DataSource</code> this runner is using.
  +     */
  +    public DataSource getDataSource() {
  +        return this.ds;
  +    }
  +
  +    /**
  +     * Execute an SQL SELECT query with a single replacement parameter.  The
  +     * caller is responsible for connection cleanup.
  +     * 
  +     * @param conn The connection to execute the query in.
  +     * @param sql The query to execute.
  +     * @param param The replacement parameter.
  +     * @param rsh The handler that converts the results into an object.
  +     * @return The object returned by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(
  +        Connection conn,
  +        String sql,
  +        Object param,
  +        ResultSetHandler rsh)
  +        throws SQLException {
  +
  +        return this.query(conn, sql, new Object[] { param }, rsh);
  +    }
  +
  +    /**
  +     * Execute an SQL SELECT query with replacement parameters.  The
  +     * caller is responsible for connection cleanup.
  +     * 
  +     * @param conn The connection to execute the query in.
  +     * @param sql The query to execute.
  +     * @param params The replacement parameters.
  +     * @param rsh The handler that converts the results into an object.
  +     * @return The object returned by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(
  +        Connection conn,
  +        String sql,
  +        Object[] params,
  +        ResultSetHandler rsh)
  +        throws SQLException {
  +
  +        PreparedStatement stmt = null;
  +        ResultSet rs = null;
  +        Object result = null;
  +
  +        try {
  +            stmt = conn.prepareStatement(sql);
  +            this.fillStatement(stmt, params);
  +
  +            rs = this.wrap(stmt.executeQuery());
  +
  +            result = rsh.handle(rs);
  +
  +        } catch (SQLException e) {
  +            this.rethrow(e, sql, params);
  +
  +        } finally {
  +            DbUtils.closeQuietly(rs);
  +            DbUtils.closeQuietly(stmt);
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Execute an SQL SELECT query without any replacement parameters.  The
  +     * caller is responsible for connection cleanup.
  +     * 
  +     * @param conn The connection to execute the query in.
  +     * @param sql The query to execute.
  +     * @param rsh The handler that converts the results into an object.
  +     * @return The object returned by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(Connection conn, String sql, ResultSetHandler rsh)
  +        throws SQLException {
  +
  +        return this.query(conn, sql, (Object[]) null, rsh);
  +    }
  +
  +    /**
  +     * Executes the given SELECT SQL with a single replacement parameter.
  +     * The <code>Connection</code> is retrieved from the
  +     * <code>DataSource</code> set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @param param The replacement parameter.
  +     * @param rsh The handler used to create the result object from 
  +     * the <code>ResultSet</code>.
  +     * 
  +     * @return An object generated by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(String sql, Object param, ResultSetHandler rsh)
  +        throws SQLException {
  +
  +        return this.query(sql, new Object[] { param }, rsh);
  +    }
  +
  +    /**
  +     * Executes the given SELECT SQL query and returns a result object.
  +     * The <code>Connection</code> is retrieved from the 
  +     * <code>DataSource</code> set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @param params Initialize the PreparedStatement's IN parameters with 
  +     * this array.
  +     * 
  +     * @param rsh The handler used to create the result object from 
  +     * the <code>ResultSet</code>.
  +     * 
  +     * @return An object generated by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(String sql, Object[] params, ResultSetHandler rsh)
  +        throws SQLException {
  +
  +        Connection conn = this.ds.getConnection();
  +
  +        Object result = null;
  +
  +        try {
  +            result = this.query(conn, sql, params, rsh);
  +
  +        } finally {
  +            DbUtils.closeQuietly(conn);
  +        }
  +
  +        return result;
  +    }
  +
  +    /**
  +     * Executes the given SELECT SQL without any replacement parameters.
  +     * The <code>Connection</code> is retrieved from the
  +     * <code>DataSource</code> set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @param rsh The handler used to create the result object from 
  +     * the <code>ResultSet</code>.
  +     * 
  +     * @return An object generated by the handler.
  +     * @throws SQLException
  +     */
  +    public Object query(String sql, ResultSetHandler rsh) throws SQLException {
  +        return this.query(sql, (Object[]) null, rsh);
  +    }
  +
  +    /**
  +     * Throws a new exception with a more informative error message.
  +     * 
  +     * @param cause The original exception that will be chained to the new 
  +     * 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.
  +     * 
  +     * @throws SQLException
  +     */
  +    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());
  +        }
  +
  +        SQLException newsqle = new SQLException(msg.toString());
  +        newsqle.setNextException(cause);
  +
  +        throw newsqle;
  +    }
  +
  +    /**
  +     * Sets the <code>DataSource</code> this runner will use to get
  +     * database connections from.  This should be called after creating a
  +     * runner with the default constructor if you intend to use the
  +     * execute methods without passing in a <code>Connection</code>.
  +     * 
  +     * @param dataSource The DataSource to use.
  +     */
  +    public void setDataSource(DataSource dataSource) {
  +        this.ds = dataSource;
  +    }
  +
  +    /**
  +     * Execute an SQL INSERT, UPDATE, or DELETE query without replacement
  +     * parameters.
  +     * 
  +     * @param conn The connection to use to run the query.
  +     * @param sql The SQL to execute.
  +     * @return The number of rows updated.
  +     * @throws SQLException
  +     */
  +    public int update(Connection conn, String sql) throws SQLException {
  +        return this.update(conn, sql, (Object[]) null);
  +    }
  +
  +    /**
  +     * Execute an SQL INSERT, UPDATE, or DELETE query with a single replacement
  +     * parameter.
  +     * 
  +     * @param conn The connection to use to run the query.
  +     * @param sql The SQL to execute.
  +     * @param param The replacement parameter.
  +     * @return The number of rows updated.
  +     * @throws SQLException
  +     */
  +    public int update(Connection conn, String sql, Object param)
  +        throws SQLException {
  +
  +        return this.update(conn, sql, new Object[] { param });
  +    }
  +
  +    /**
  +     * Execute an SQL INSERT, UPDATE, or DELETE query.
  +     * 
  +     * @param conn The connection to use to run the query.
  +     * @param sql The SQL to execute.
  +     * @param params The query replacement parameters.
  +     * @return The number of rows updated.
  +     * @throws SQLException
  +     */
  +    public int update(Connection conn, String sql, Object[] params)
  +        throws SQLException {
  +
  +        PreparedStatement stmt = null;
  +        int rows = 0;
  +
  +        try {
  +            stmt = conn.prepareStatement(sql);
  +            this.fillStatement(stmt, params);
  +
  +            rows = stmt.executeUpdate();
  +
  +        } catch (SQLException e) {
  +            this.rethrow(e, sql, params);
  +
  +        } finally {
  +            DbUtils.closeQuietly(stmt);
  +        }
  +
  +        return rows;
  +    }
  +
  +    /**
  +     * Executes the given INSERT, UPDATE, or DELETE SQL statement without
  +     * any replacement parameters.  The statement is executed in its own 
  +     * transaction that will be committed or rolled back depending on any 
  +     * SQLExceptions thrown.  The <code>Connection</code> is retrieved from the
  +     * <code>DataSource</code> set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @throws SQLException
  +     * @return The number of rows updated.
  +     */
  +    public int update(String sql) throws SQLException {
  +        return this.update(sql, (Object[]) null);
  +    }
  +
  +    /**
  +     * Executes the given INSERT, UPDATE, or DELETE SQL statement with
  +     * a single replacement parameter.  The statement is executed in its own 
  +     * transaction that will be committed or rolled back depending on any 
  +     * SQLExceptions thrown.  The <code>Connection</code> is retrieved from the
  +     * <code>DataSource</code> set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @param param The replacement parameter.
  +     * @throws SQLException
  +     * @return The number of rows updated.
  +     */
  +    public int update(String sql, Object param) throws SQLException {
  +        return this.update(sql, new Object[] { param });
  +    }
  +
  +    /**
  +     * Executes the given INSERT, UPDATE, or DELETE SQL statement.  The 
  +     * statement is executed in its own transaction that will be committed or 
  +     * rolled back depending on any SQLExceptions thrown.  The 
  +     * <code>Connection</code> is retrieved from the <code>DataSource</code> 
  +     * set in the constructor.
  +     * 
  +     * @param sql The SQL statement to execute.
  +     * @param params Initializes the PreparedStatement's IN (ie. '?') 
  +     * parameters.
  +     * @throws SQLException
  +     * @return The number of rows updated.
  +     */
  +    public int update(String sql, Object[] params) throws SQLException {
  +
  +        Connection conn = this.ds.getConnection();
  +        int rows = 0;
  +
  +        try {
  +            conn.setAutoCommit(false); // single transaction.
  +            rows = this.update(conn, sql, params);
  +            conn.commit();
  +
  +        } catch (SQLException e) {
  +            DbUtils.rollback(conn);
  +            throw e;
  +
  +        } finally {
  +            DbUtils.closeQuietly(conn);
  +        }
  +
  +        return rows;
  +    }
  +
  +    /**
  +     * Wrap the <code>ResultSet</code> in a decorator before processing it.
  +     * This implementation returns the <code>ResultSet</code> it is given
  +     * without any decoration.
  +     *
  +     * <p>
  +     * Often, the implementation of this method can be done in an anonymous 
  +     * inner class like this:
  +     * </p>
  +     * <pre> 
  +     * QueryRunner run = new QueryRunner() {
  +     *     protected void wrap(ResultSet rs) {
  +     *         return StringTrimmedResultSet.wrap(rs);
  +     *     }
  +     * };
  +     * </pre>
  +     * 
  +     * @param rs The <code>ResultSet</code> to decorate; never 
  +     * <code>null</code>.
  +     * @return The <code>ResultSet</code> wrapped in some decorator. 
  +     */
  +    protected ResultSet wrap(ResultSet rs) {
  +        return rs;
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
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