You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/06/12 14:13:44 UTC

svn commit: r413642 [10/12] - in /incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java: java/sql/ javax/sql/ javax/transaction/ javax/transaction/xa/ org/apache/harmony/sql/internal/common/

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java Mon Jun 12 05:13:42 2006
@@ -13,342 +13,430 @@
  * limitations under the License.
  */
 
-
 package java.sql;
 
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.io.Serializable;
-import java.lang.IllegalArgumentException;
 import java.text.DecimalFormat;
 import java.text.ParsePosition;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 
 /**
- * A Java representation of the SQL TIMESTAMP type.  It provides the capability to represent
- * the SQL TIMESTAMP nanosecond value, in addition to the regular date/time value which has
- * millisecond resolution.
+ * A Java representation of the SQL TIMESTAMP type. It provides the capability
+ * to represent the SQL TIMESTAMP nanosecond value, in addition to the regular
+ * date/time value which has millisecond resolution.
  * <p>
- * The Timestamp class consists of a regular Date/Time value, where only the integral seconds
- * value is stored, plus a nanoseconds value where the fractional seconds are stored.
+ * The Timestamp class consists of a regular Date/Time value, where only the
+ * integral seconds value is stored, plus a nanoseconds value where the
+ * fractional seconds are stored.
  * <p>
- * The addition of the nanosecond value field to the Timestamp object makes it significantly
- * different from the java.util.Date object which it extends.  Users should be cautious in 
- * their use of Timestamp objects and should not assume that they are interchangeable with
- * java.util.Date objects when used outside the confines of the java.sql package.  
+ * The addition of the nanosecond value field to the Timestamp object makes it
+ * significantly different from the java.util.Date object which it extends.
+ * Users should be cautious in their use of Timestamp objects and should not
+ * assume that they are interchangeable with java.util.Date objects when used
+ * outside the confines of the java.sql package.
  * 
  */
 public class Timestamp extends Date {
-	
-	private static final long serialVersionUID = 2745179027874758501L;
-	
-	// The nanoseconds time value of the Timestamp
-	private int nanoseconds;
-
-	/**
-	 * @deprecated Please use the constructor Timestamp( long )
-	 * Returns a Timestamp corresponding to the time specified by the supplied values for Year, Month,
-	 * Date, Hour, Minutes, Seconds and Nanoseconds 
-	 * @param theYear specified as the year minus 1900
-	 * @param theMonth specified as an integer in the range 0 - 11
-	 * @param theDate specified as an integer in the range 1 - 31
-	 * @param theHour specified as an integer in the range 0 - 23
-	 * @param theMinute specified as an integer in the range 0 - 59
-	 * @param theSecond specified as an integer in the range 0 - 59
-	 * @param theNano which defines the nanosecond value of the timestamp specified as an integer
-	 * in the range 0 - 999,999,999
-	 * @throws IllegalArgumentException if any of the parameters is out of range
-	 */
-	public Timestamp( int theYear, int theMonth, int theDate, int theHour, 
-					  int theMinute, int theSecond, int theNano ) 
-					  throws IllegalArgumentException {
- 		super( theYear, theMonth, theDate, theHour, theMinute, theSecond );
- 		if( theNano < 0 || theNano > 999999999 ) throw new IllegalArgumentException();		
-		nanoseconds = theNano;
-	} // end method Timestamp( int, int, int, int, int, int )
-	
-	/**
-	 * Returns a Timestamp object corresponding to the time represented by a supplied time value.
-	 * 
-	 * @param theTime a time value in the format of milliseconds since the Epoch 
-	 * (January 1 1970 00:00:00.000 GMT)
-	 */
-	public Timestamp(long theTime) {
-		super( theTime );
-		// Now set the time for this Timestamp object - which deals with the nanosecond value
-		// as well as the base time
-		this.setTime( theTime );
-		// System.out.println("Clear version of java.sql.Timestamp");
-	} // end method Timestamp( long )
-	
-	/**
-	 * Returns true if this timestamp object is later than the supplied timestamp,
-	 * otherwise returns false.
-	 * @param theTimestamp the timestamp to compare with this timestamp object
-	 * @return true if this timestamp object is later than the supplied timestamp, false
-	 * otherwise
-	 */
-	public boolean after( Timestamp theTimestamp ) {
-		long thisTime = this.getTime();
-		long compareTime = theTimestamp.getTime();
-		
-		// If the time value is later, the timestamp is later
-		if ( thisTime > compareTime ) { return true; }
-		// If the time value is earlier, the timestamp is not later
-		else if ( thisTime < compareTime ) { return false; }
-		// Otherwise the time values are equal in which case the nanoseconds value
-		// determines whether this timestamp is later...
-		else if ( this.getNanos() > theTimestamp.getNanos() ) { return true; }
-		else { return false; } // end if
-		
-	} // end method after( Timestamp )
-    
-	/**
-	 * Returns true if this timestamp object is earlier than the supplied timestamp,
-	 * otherwise returns false.
-	 * @param theTimestamp the timestamp to compare with this timestamp object
-	 * @return true if this timestamp object is earlier than the supplied timestamp, false
-	 * otherwise
-	 */
-	public boolean before( Timestamp theTimestamp ) {
-		long thisTime = this.getTime();
-		long compareTime = theTimestamp.getTime();
-		
-		// If the time value is later, the timestamp is later
-		if ( thisTime < compareTime ) { return true; }
-		// If the time value is earlier, the timestamp is not later
-		else if ( thisTime > compareTime ) { return false; }
-		// Otherwise the time values are equal in which case the nanoseconds value
-		// determines whether this timestamp is later...
-		else if ( this.getNanos() < theTimestamp.getNanos() ) { return true; }
-		else { return false; } // end if
-		
-	} // end method before( Timestamp )
-    
-	/**
-	 * Compares this Timestamp object with a supplied Timestamp object
-	 * @param theObject the timestamp to compare with this timestamp object, passed in as an Object
-	 * @return 0 if the two Timestamp objects are equal in time, a value <0 if this Timestamp object is
-	 * before the supplied Timestamp and a value >0 if this Timestamp object is after the supplied
-	 * Timestamp
-	 * @throws ClassCastException if the supplied object is not a Timestamp object
-	 */
-	public int compareTo( Date theObject ) throws ClassCastException {
-		return this.compareTo( (Timestamp) theObject );
-	} // end method compareTo( Object )
-    
-	/**
-	 * Compares this Timestamp object with a supplied Timestamp object
-	 * @param theTimestamp the timestamp to compare with this timestamp object, passed in as a Timestamp
-	 * @return 0 if the two Timestamp objects are equal in time, a value <0 if this Timestamp object is
-	 * before the supplied Timestamp and a value >0 if this Timestamp object is after the supplied
-	 * Timestamp
-	 */
-	public int compareTo( Timestamp theTimestamp ) {
-		if ( this.before( theTimestamp ) ) { return -1; }
-		else if ( this.after( theTimestamp ) ) { return +1; }
-		else return 0;
-	} // end method compareTo( Timestamp )
-	
-	/**
-	 * Tests to see if this timestamp is equal to a supplied object.
-	 * @param theObject 
-	 * @return true if this Timestamp object is equal to the supplied Timestamp object
-	 * false if the object is not a Timestamp object or if the object is a Timestamp but
-	 * represents a different instant in time
-	 */
+
+    private static final long serialVersionUID = 2745179027874758501L;
+
+    // The nanoseconds time value of the Timestamp
+    private int nanoseconds;
+
+    /**
+     * @deprecated Please use the constructor Timestamp( long ) Returns a
+     *             Timestamp corresponding to the time specified by the supplied
+     *             values for Year, Month, Date, Hour, Minutes, Seconds and
+     *             Nanoseconds
+     * @param theYear
+     *            specified as the year minus 1900
+     * @param theMonth
+     *            specified as an integer in the range 0 - 11
+     * @param theDate
+     *            specified as an integer in the range 1 - 31
+     * @param theHour
+     *            specified as an integer in the range 0 - 23
+     * @param theMinute
+     *            specified as an integer in the range 0 - 59
+     * @param theSecond
+     *            specified as an integer in the range 0 - 59
+     * @param theNano
+     *            which defines the nanosecond value of the timestamp specified
+     *            as an integer in the range 0 - 999,999,999
+     * @throws IllegalArgumentException
+     *             if any of the parameters is out of range
+     */
+    public Timestamp(int theYear, int theMonth, int theDate, int theHour,
+            int theMinute, int theSecond, int theNano)
+            throws IllegalArgumentException {
+        super(theYear, theMonth, theDate, theHour, theMinute, theSecond);
+        if (theNano < 0 || theNano > 999999999) {
+            throw new IllegalArgumentException();
+        }
+        nanoseconds = theNano;
+    }
+
+    /**
+     * Returns a Timestamp object corresponding to the time represented by a
+     * supplied time value.
+     * 
+     * @param theTime
+     *            a time value in the format of milliseconds since the Epoch
+     *            (January 1 1970 00:00:00.000 GMT)
+     */
+    public Timestamp(long theTime) {
+        super(theTime);
+        /*
+         * Now set the time for this Timestamp object - which deals with the
+         * nanosecond value as well as the base time
+         */
+        this.setTime(theTime);
+    }
+
+    /**
+     * Returns true if this timestamp object is later than the supplied
+     * timestamp, otherwise returns false.
+     * 
+     * @param theTimestamp
+     *            the timestamp to compare with this timestamp object
+     * @return true if this timestamp object is later than the supplied
+     *         timestamp, false otherwise
+     */
+    public boolean after(Timestamp theTimestamp) {
+        long thisTime = this.getTime();
+        long compareTime = theTimestamp.getTime();
+
+        // If the time value is later, the timestamp is later
+        if (thisTime > compareTime) {
+            return true;
+        }
+        // If the time value is earlier, the timestamp is not later
+        else if (thisTime < compareTime) {
+            return false;
+        }
+        /*
+         * Otherwise the time values are equal in which case the nanoseconds
+         * value determines whether this timestamp is later...
+         */
+        else if (this.getNanos() > theTimestamp.getNanos()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns true if this timestamp object is earlier than the supplied
+     * timestamp, otherwise returns false.
+     * 
+     * @param theTimestamp
+     *            the timestamp to compare with this timestamp object
+     * @return true if this timestamp object is earlier than the supplied
+     *         timestamp, false otherwise
+     */
+    public boolean before(Timestamp theTimestamp) {
+        long thisTime = this.getTime();
+        long compareTime = theTimestamp.getTime();
+
+        // If the time value is later, the timestamp is later
+        if (thisTime < compareTime) {
+            return true;
+        }
+        // If the time value is earlier, the timestamp is not later
+        else if (thisTime > compareTime) {
+            return false;
+        }
+        /*
+         * Otherwise the time values are equal in which case the nanoseconds
+         * value determines whether this timestamp is later...
+         */
+        else if (this.getNanos() < theTimestamp.getNanos()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Compares this Timestamp object with a supplied Timestamp object
+     * 
+     * @param theObject
+     *            the timestamp to compare with this timestamp object, passed in
+     *            as an Object
+     * @return 0 if the two Timestamp objects are equal in time, a value <0 if
+     *         this Timestamp object is before the supplied Timestamp and a
+     *         value >0 if this Timestamp object is after the supplied Timestamp
+     * @throws ClassCastException
+     *             if the supplied object is not a Timestamp object
+     */
+    public int compareTo(Date theObject) throws ClassCastException {
+        return this.compareTo((Timestamp) theObject);
+    }
+
+    /**
+     * Compares this Timestamp object with a supplied Timestamp object
+     * 
+     * @param theTimestamp
+     *            the timestamp to compare with this timestamp object, passed in
+     *            as a Timestamp
+     * @return 0 if the two Timestamp objects are equal in time, a value <0 if
+     *         this Timestamp object is before the supplied Timestamp and a
+     *         value >0 if this Timestamp object is after the supplied Timestamp
+     */
+    public int compareTo(Timestamp theTimestamp) {
+        if (this.before(theTimestamp)) {
+            return -1;
+        } else if (this.after(theTimestamp)) {
+            return +1;
+        } else {
+            return 0;
+        }
+    }
+
+    /**
+     * Tests to see if this timestamp is equal to a supplied object.
+     * 
+     * @param theObject
+     * @return true if this Timestamp object is equal to the supplied Timestamp
+     *         object false if the object is not a Timestamp object or if the
+     *         object is a Timestamp but represents a different instant in time
+     */
     public boolean equals(Object theObject) {
         if (theObject instanceof Timestamp) {
             return equals((Timestamp) theObject);
         }
         return false;
-    } // end method equals( Object )
-    
-	/**
-	 * Tests to see if this timestamp is equal to a supplied timestamp.
-	 * @param theTimestamp the timestamp to compare with this timestamp object, passed in as an Object
-	 * @return true if this Timestamp object is equal to the supplied Timestamp object
-	 */
-    public boolean equals( Timestamp theTimestamp ) {
+    }
+
+    /**
+     * Tests to see if this timestamp is equal to a supplied timestamp.
+     * 
+     * @param theTimestamp
+     *            the timestamp to compare with this timestamp object, passed in
+     *            as an Object
+     * @return true if this Timestamp object is equal to the supplied Timestamp
+     *         object
+     */
+    public boolean equals(Timestamp theTimestamp) {
         if (theTimestamp == null) {
             return false;
         }
-    	if( (this.getTime() == theTimestamp.getTime()) && (this.getNanos() == theTimestamp.getNanos()) ) {
-    		return true;
-    	} else {
-    		return false;
-    	}
-    } // end method equals( Timestamp )
-    
+        return (this.getTime() == theTimestamp.getTime())
+                && (this.getNanos() == theTimestamp.getNanos());
+    }
+
     /**
      * Gets this Timestamp's nanosecond value
-     * @return The timestamp's nanosecond value, an integer between 0 and 999,999,999
+     * 
+     * @return The timestamp's nanosecond value, an integer between 0 and
+     *         999,999,999
      */
     public int getNanos() {
-    	return nanoseconds;
-    } // end method getNanos()
-    
+        return nanoseconds;
+    }
+
     /**
-     * Returns the time represented by this Timestamp object, as a long value containing the number of
-     * milliseconds since the Epoch (January 1 1970, 00:00:00.000 GMT)
+     * Returns the time represented by this Timestamp object, as a long value
+     * containing the number of milliseconds since the Epoch (January 1 1970,
+     * 00:00:00.000 GMT)
      */
     public long getTime() {
-    	long theTime = super.getTime();
-    	theTime = theTime + (long)(nanoseconds / 1000000 );
-    	return theTime;
-    } // end method getTime()
-    
+        long theTime = super.getTime();
+        theTime = theTime + (nanoseconds / 1000000);
+        return theTime;
+    }
+
     /**
      * Sets the nanosecond value for this timestamp
      */
     public void setNanos(int n) throws IllegalArgumentException {
-    	if ( (n < 0) || (n > 999999999 ) ) throw new IllegalArgumentException("Nanos value out of range.");
-    	nanoseconds = n;
-    } // end method setNanos( int )
-    
+        if ((n < 0) || (n > 999999999)) {
+            throw new IllegalArgumentException("Nanos value out of range.");
+        }
+        nanoseconds = n;
+    }
+
     /**
-     * Sets the time represented by this Timestamp object to the supplied time, defined as the number
-     * of milliseconds since the Epoch (January 1 1970, 00:00:00.000 GMT)
+     * Sets the time represented by this Timestamp object to the supplied time,
+     * defined as the number of milliseconds since the Epoch (January 1 1970,
+     * 00:00:00.000 GMT)
      */
     public void setTime(long theTime) {
-		// Deal with the nanoseconds value.  The supplied time is in milliseconds - so we must
-		// extract the milliseconds value and multiply by 1000000 to get nanoseconds.
-		// Things are more complex if theTime value is negative, since then the time
-		// value is the time before the Epoch but the nanoseconds value of the Timestamp must
-		// be positive - so we must take the "raw" milliseconds value and subtract it from
-		// 1000 to get to the true nanoseconds value
-		// Simultaneously, recalculate the time value to the exact nearest second and reset 
-		// the Date time value
-		int milliseconds = (int)(theTime % 1000);
-		theTime = theTime - milliseconds;
-		if ( milliseconds < 0 ) {
-			theTime = theTime - 1000;
-			milliseconds = 1000 + milliseconds;	
-		} // end if
-		super.setTime( theTime );
-		setNanos( milliseconds * 1000000 );
-    } // end method setTime( long )
-    
-    /**
-     * Returns the timestamp formatted as a String in the JDBC Timestamp Escape format, which is of the
-     * form "yyyy-mm-dd hh:mm:ss.nnnnnnnnn"
-     * @return A string representing the instant defined by the Timestamp, in JDBC Timestamp 
-     * escape format
+        /*
+         * Deal with the nanoseconds value. The supplied time is in milliseconds -
+         * so we must extract the milliseconds value and multiply by 1000000 to
+         * get nanoseconds. Things are more complex if theTime value is
+         * negative, since then the time value is the time before the Epoch but
+         * the nanoseconds value of the Timestamp must be positive - so we must
+         * take the "raw" milliseconds value and subtract it from 1000 to get to
+         * the true nanoseconds value Simultaneously, recalculate the time value
+         * to the exact nearest second and reset the Date time value
+         */
+        int milliseconds = (int) (theTime % 1000);
+        theTime = theTime - milliseconds;
+        if (milliseconds < 0) {
+            theTime = theTime - 1000;
+            milliseconds = 1000 + milliseconds;
+        }
+        super.setTime(theTime);
+        setNanos(milliseconds * 1000000);
+    }
+
+    /**
+     * Returns the timestamp formatted as a String in the JDBC Timestamp Escape
+     * format, which is of the form "yyyy-mm-dd hh:mm:ss.nnnnnnnnn"
+     * 
+     * @return A string representing the instant defined by the Timestamp, in
+     *         JDBC Timestamp escape format
      */
     public String toString() {
-    	// A SimpleDateFormat will lay out everything except the nanosecond value
-		SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" );
-		
-		// Use a DecimalFormat to lay out the nanosecond value as a simple string of
-		// 9 integers, with leading Zeros
-		DecimalFormat decimalFormat = new DecimalFormat("0");
-		decimalFormat.setMinimumIntegerDigits( 9 );
-		decimalFormat.setMaximumIntegerDigits( 9 );
-		String theNanos = decimalFormat.format( (long) nanoseconds ); 
-		theNanos = stripTrailingZeros( theNanos );
-		// Concatenate the nanosecond value with a dot - and return
-		return (dateFormat.format( this ) + '.' + theNanos);
-    } // end method toString()
-    
+        // A SimpleDateFormat will lay out everything except the nanosecond
+        // value
+        SimpleDateFormat dateFormat = new SimpleDateFormat(
+                "yyyy-MM-dd HH:mm:ss");
+
+        /*
+         * Use a DecimalFormat to lay out the nanosecond value as a simple
+         * string of 9 integers, with leading Zeros
+         */
+        DecimalFormat decimalFormat = new DecimalFormat("0");
+        decimalFormat.setMinimumIntegerDigits(9);
+        decimalFormat.setMaximumIntegerDigits(9);
+        String theNanos = decimalFormat.format(nanoseconds);
+        theNanos = stripTrailingZeros(theNanos);
+        // Concatenate the nanosecond value with a dot - and return
+        return (dateFormat.format(this) + '.' + theNanos);
+    }
+
     /*
-     * Private method to strip trailing '0' characters from a string.
-     * @param inputString the starting string
-     * @return a string with the trailing zeros stripped - will leave
-     * a single 0 at the beginning of the string 
-     */
-    private String stripTrailingZeros( String inputString ) {
-    	String finalString;
-    	
-    	int i;
-    	for( i = inputString.length(); i > 0 ; i-- ) {
-    		if( inputString.charAt(i-1) != '0' ) break;
-    		// If the string has a 0 as its first character, return
-    		// a string with a single '0'
-    		if ( i == 1 ) return "0";
-    	} // end for
-    	
-    	finalString = inputString.substring(0, i);
-    	return finalString;
-    } // end stripTrailingZeros( String )
-    
-    private static String	valueOfExceptionMessage = 
-    	"Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff";
-    /**
-     * Creates a Timestamp object with a time value equal to the time specified by a supplied String
-     * holding the time in JDBC timestamp escape format, which is of the form
-     * "yyyy-mm-dd hh:mm:ss.nnnnnnnnn"
-     * @param s the String containing a time in JDBC timestamp escape format
-     * @return A timestamp object with time value as defined by the supplied String
-     */
-    public static Timestamp valueOf( String s ) throws IllegalArgumentException {
-    	if( s == null ) throw new IllegalArgumentException("null string");
-    	
-    	SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    	ParsePosition pp = new ParsePosition( 0 );
-    	
-    	// First parse out the yyyy-MM-dd HH:mm:ss component of the String into a Date object
-    	// using the SimpleDateFormat.  This should stop after the seconds value, according to
-    	// the definition of SimpleDateFormat.parse, with the ParsePosition indicating the
-    	// index of the "." which should precede the nanoseconds value
-    	Date theDate;
-    	try {
-    		theDate = df.parse( s, pp );
-    	} catch (Exception e) {
-    		throw new IllegalArgumentException(valueOfExceptionMessage);
-    	} // end try
-    	
-    	if( theDate == null ) throw new IllegalArgumentException(valueOfExceptionMessage);
-    	
-    	/* If we get here, the Date part of the string was OK - now for the nanoseconds
-    	 * value.  Strictly, this requires the remaining part of the String to look like
-    	 * ".nnnnnnnnn".  However, we accept anything with a '.' followed by 1 to 9
-    	 * digits - we also accept nothing (no fractions of a second).
-    	 * Anything else is interpreted as incorrect format which will
-    	 * generate an IllegalArgumentException
-    	 */
-    	int position = pp.getIndex();
-    	int remaining = s.length() - position;
-    	int theNanos;
-    	
-    	if( remaining == 0 ) {
-    	    // First, allow for the case where no fraction of a second is given:
-    	    theNanos = 0;
-    	} else {
-    	    // Case where fraction of a second is specified:
-	    	// Require 1 character plus the "." in the remaining part of the string...
-	    	if( (s.length() - position) < ".n".length() ) throw new IllegalArgumentException(valueOfExceptionMessage);
-	    	
-	    	// If we're strict, we should not allow any EXTRA characters after the 9 digits
-	    	if( (s.length() - position) > ".nnnnnnnnn".length() ) throw new IllegalArgumentException(valueOfExceptionMessage);
-	    	
-	    	// Require the next character to be a "."
-	    	if( s.charAt(position) != '.' ) throw new NumberFormatException("Bad input string format - '" + s.charAt(position) + "' instead of '.'");
-	    	// Get the length of the number string - need to account for the '.'
-	    	int nanoLength = s.length() - position - 1 ;
-	    	    	
-	    	// Get the 9 characters following the "." as an integer
-	    	String theNanoString = s.substring( position+1, position+1+nanoLength );
-	    	// We must adjust for the cases where the nanos String was not 9 characters long
-	    	// by padding out with zeros
-	    	theNanoString = theNanoString + "000000000";
-	    	theNanoString = theNanoString.substring(0, 9);
-	    	
-	    	try {
-	    		theNanos = Integer.parseInt( theNanoString );
-	    	} catch (Exception e) {
-	    		// If we get here, the string was not a number
-	    		throw new IllegalArgumentException(valueOfExceptionMessage);
-	    	} // end try
-    	} // end if
-    	
-    	if ( theNanos < 0 || theNanos > 999999999 ) throw new IllegalArgumentException(valueOfExceptionMessage);
-    	
-    	Timestamp theTimestamp = new Timestamp( theDate.getTime() );
-    	theTimestamp.setNanos( theNanos );
-    	
-    	return theTimestamp;
-    } // end method valueOf( String )
-    
-	
-}
+     * Private method to strip trailing '0' characters from a string. @param
+     * inputString the starting string @return a string with the trailing zeros
+     * stripped - will leave a single 0 at the beginning of the string
+     */
+    private String stripTrailingZeros(String inputString) {
+        String finalString;
+
+        int i;
+        for (i = inputString.length(); i > 0; i--) {
+            if (inputString.charAt(i - 1) != '0') {
+                break;
+            }
+            /*
+             * If the string has a 0 as its first character, return a string
+             * with a single '0'
+             */
+            if (i == 1) {
+                return "0";
+            }
+        }
+
+        finalString = inputString.substring(0, i);
+        return finalString;
+    }
 
+    private static String valueOfExceptionMessage = "Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff";
 
+    /**
+     * Creates a Timestamp object with a time value equal to the time specified
+     * by a supplied String holding the time in JDBC timestamp escape format,
+     * which is of the form "yyyy-mm-dd hh:mm:ss.nnnnnnnnn"
+     * 
+     * @param s
+     *            the String containing a time in JDBC timestamp escape format
+     * @return A timestamp object with time value as defined by the supplied
+     *         String
+     */
+    public static Timestamp valueOf(String s) throws IllegalArgumentException {
+        if (s == null) {
+            throw new IllegalArgumentException("null string");
+        }
+
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        ParsePosition pp = new ParsePosition(0);
+
+        /*
+         * First parse out the yyyy-MM-dd HH:mm:ss component of the String into
+         * a Date object using the SimpleDateFormat. This should stop after the
+         * seconds value, according to the definition of SimpleDateFormat.parse,
+         * with the ParsePosition indicating the index of the "." which should
+         * precede the nanoseconds value
+         */
+        Date theDate;
+        try {
+            theDate = df.parse(s, pp);
+        } catch (Exception e) {
+            throw new IllegalArgumentException(valueOfExceptionMessage);
+        }
+
+        if (theDate == null) {
+            throw new IllegalArgumentException(valueOfExceptionMessage);
+        }
+
+        /*
+         * If we get here, the Date part of the string was OK - now for the
+         * nanoseconds value. Strictly, this requires the remaining part of the
+         * String to look like ".nnnnnnnnn". However, we accept anything with a
+         * '.' followed by 1 to 9 digits - we also accept nothing (no fractions
+         * of a second). Anything else is interpreted as incorrect format which
+         * will generate an IllegalArgumentException
+         */
+        int position = pp.getIndex();
+        int remaining = s.length() - position;
+        int theNanos;
+
+        if (remaining == 0) {
+            // First, allow for the case where no fraction of a second is given:
+            theNanos = 0;
+        } else {
+            /*
+             * Case where fraction of a second is specified: Require 1 character
+             * plus the "." in the remaining part of the string...
+             */
+            if ((s.length() - position) < ".n".length()) {
+                throw new IllegalArgumentException(valueOfExceptionMessage);
+            }
+
+            /*
+             * If we're strict, we should not allow any EXTRA characters after
+             * the 9 digits
+             */
+            if ((s.length() - position) > ".nnnnnnnnn".length()) {
+                throw new IllegalArgumentException(valueOfExceptionMessage);
+            }
+
+            // Require the next character to be a "."
+            if (s.charAt(position) != '.') {
+                throw new NumberFormatException("Bad input string format - '"
+                        + s.charAt(position) + "' instead of '.'");
+            }
+            // Get the length of the number string - need to account for the '.'
+            int nanoLength = s.length() - position - 1;
+
+            // Get the 9 characters following the "." as an integer
+            String theNanoString = s.substring(position + 1, position + 1
+                    + nanoLength);
+            /*
+             * We must adjust for the cases where the nanos String was not 9
+             * characters long by padding out with zeros
+             */
+            theNanoString = theNanoString + "000000000";
+            theNanoString = theNanoString.substring(0, 9);
+
+            try {
+                theNanos = Integer.parseInt(theNanoString);
+            } catch (Exception e) {
+                // If we get here, the string was not a number
+                throw new IllegalArgumentException(valueOfExceptionMessage);
+            }
+        }
+
+        if (theNanos < 0 || theNanos > 999999999) {
+            throw new IllegalArgumentException(valueOfExceptionMessage);
+        }
+
+        Timestamp theTimestamp = new Timestamp(theDate.getTime());
+        theTimestamp.setNanos(theNanos);
+
+        return theTimestamp;
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Types.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Types.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Types.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Types.java Mon Jun 12 05:13:42 2006
@@ -11,180 +11,172 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package java.sql;
-
-/**
- * A class which defines constants used to identify generic SQL types, also called JDBC
- * types. The type constant values are equivalent to those in XOPEN.
- * 
- */
-public class Types {
-
-	// Uncomment the following to validate that this version of java.sql.Types is
-	// loaded:
-	// static { System.out.println("Clear version of java.sql.Types loaded!"); }; 
-	
-	/*
-	 * Private constructor to prevent instantiation.
-	 */
-	private Types() {
-		
-	} // end constructor Types()
-	
-	/**
-	 * The type code that identifies the SQL type ARRAY.
-	 */
-	public static final int 	ARRAY 		= 2003 ;
-	
-	/**
-	 * The type code that identifies the SQL type BIGINT.
-	 */
-	public static final int 	BIGINT		= -5 ;
-	
-	/**
-	 * The type code that identifies the SQL type BINARY.
-	 */
-	public static final int 	BINARY		= -2 ;
-	
-	/**
-	 * The type code that identifies the SQL type BIT.
-	 */
-	public static final int 	BIT			= -7 ;
-
-	/**
-	 * The type code that identifies the SQL type BLOB.
-	 */
-	public static final int 	BLOB		= 2004 ;
-    
-	/**
-	 * The type code that identifies the SQL type BOOLEAN.
-	 */
-	public static final int 	BOOLEAN		= 16 ;
-    
-	/**
-	 * The type code that identifies the SQL type CHAR.
-	 */
-	public static final int 	CHAR		= 1 ;
-    
-	/**
-	 * The type code that identifies the SQL type CLOB.
-	 */
-	public static final int 	CLOB		= 2005 ;
-	
-	/**
-	 * The type code that identifies the SQL type DATALINK.
-	 */
-    public static final int 	DATALINK	= 70 ;
-    
-	/**
-	 * The type code that identifies the SQL type DATE.
-	 */
-    public static final int 	DATE		= 91 ;
-    
-	/**
-	 * The type code that identifies the SQL type DECIMAL.
-	 */
-    public static final int 	DECIMAL		= 3 ;
-    
-	/**
-	 * The type code that identifies the SQL type DISTINCT.
-	 */
-    public static final int 	DISTINCT	= 2001 ;
-    
-	/**
-	 * The type code that identifies the SQL type DOUBLE.
-	 */
-    public static final int 	DOUBLE		= 8 ;
-    
-	/**
-	 * The type code that identifies the SQL type FLOAT.
-	 */
-    public static final int 	FLOAT		= 6 ;
-    
-	/**
-	 * The type code that identifies the SQL type INTEGER.
-	 */
-    public static final int 	INTEGER		= 4 ;
-    
-	/**
-	 * The type code that identifies the SQL type JAVA_OBJECT.
-	 */
-    public static final int 	JAVA_OBJECT	= 2000 ;
-    
-	/**
-	 * The type code that identifies the SQL type LONGVARBINARY.
-	 */
-    public static final int 	LONGVARBINARY = -4 ;
-    
-	/**
-	 * The type code that identifies the SQL type LONGVARCHAR.
-	 */
-	public static final int 	LONGVARCHAR	= -1 ;
-	
-	/**
-	 * The type code that identifies the SQL type NULL.
-	 */
-    public static final int 	NULL		= 0 ;
-    
-	/**
-	  * The type code that identifies the SQL type NUMERIC.
-	  */
-	public static final int 	NUMERIC		= 2 ;
-	
-	/**
- 	 * The type code that identifies that the SQL type is database specific and is mapped to
-	 * a Java object, accessed via the methods <code>getObject</code> and <code>setObject</code>.
-	 */
-	public static final int 	OTHER		= 1111 ;
-    
-	/**
-	 * The type code that identifies the SQL type REAL.
-	 */
-	public static final int 	REAL		= 7 ;
-    
-	/**
-	 * The type code that identifies the SQL type REF.
-	 */
-   	public static final int 	REF			= 2006 ;
-    
-	/**
-	 * The type code that identifies the SQL type SMALLINT.
-	 */
-	public static final int 	SMALLINT	= 5 ;
-    
-	/**
-	 * The type code that identifies the SQL type STRUCT.
-	 */
-    public static final int 	STRUCT		= 2002 ;
-    
-	/**
-	 * The type code that identifies the SQL type TIME.
-	 */
-	public static final int 	TIME		= 92 ;
-    
-	/**
-	 * The type code that identifies the SQL type TIMESTAMP.
-	 */
-	public static final int 	TIMESTAMP	= 93 ;
-    
-	/**
-	 * The type code that identifies the SQL type TINYINT.
-	 */
-	public static final int 	TINYINT		= -6 ;
-
-	/**
-	 * The type code that identifies the SQL type VARBINARY.
-	 */
-	public static final int 	VARBINARY	= -3 ;
-    
-	/**
-	 * The type code that identifies the SQL type VARCHAR.
-	 */
-	public static final int 	VARCHAR		= 12 ;
-	
-} // end class Types
-
-
+ */
+
+package java.sql;
+
+/**
+ * A class which defines constants used to identify generic SQL types, also
+ * called JDBC types. The type constant values are equivalent to those in XOPEN.
+ */
+public class Types {
+
+    /*
+     * Private constructor to prevent instantiation.
+     */
+    private Types() {
+        super();
+    }
+
+    /**
+     * The type code that identifies the SQL type ARRAY.
+     */
+    public static final int ARRAY = 2003;
+
+    /**
+     * The type code that identifies the SQL type BIGINT.
+     */
+    public static final int BIGINT = -5;
+
+    /**
+     * The type code that identifies the SQL type BINARY.
+     */
+    public static final int BINARY = -2;
+
+    /**
+     * The type code that identifies the SQL type BIT.
+     */
+    public static final int BIT = -7;
+
+    /**
+     * The type code that identifies the SQL type BLOB.
+     */
+    public static final int BLOB = 2004;
+
+    /**
+     * The type code that identifies the SQL type BOOLEAN.
+     */
+    public static final int BOOLEAN = 16;
+
+    /**
+     * The type code that identifies the SQL type CHAR.
+     */
+    public static final int CHAR = 1;
+
+    /**
+     * The type code that identifies the SQL type CLOB.
+     */
+    public static final int CLOB = 2005;
+
+    /**
+     * The type code that identifies the SQL type DATALINK.
+     */
+    public static final int DATALINK = 70;
+
+    /**
+     * The type code that identifies the SQL type DATE.
+     */
+    public static final int DATE = 91;
+
+    /**
+     * The type code that identifies the SQL type DECIMAL.
+     */
+    public static final int DECIMAL = 3;
+
+    /**
+     * The type code that identifies the SQL type DISTINCT.
+     */
+    public static final int DISTINCT = 2001;
+
+    /**
+     * The type code that identifies the SQL type DOUBLE.
+     */
+    public static final int DOUBLE = 8;
+
+    /**
+     * The type code that identifies the SQL type FLOAT.
+     */
+    public static final int FLOAT = 6;
+
+    /**
+     * The type code that identifies the SQL type INTEGER.
+     */
+    public static final int INTEGER = 4;
+
+    /**
+     * The type code that identifies the SQL type JAVA_OBJECT.
+     */
+    public static final int JAVA_OBJECT = 2000;
+
+    /**
+     * The type code that identifies the SQL type LONGVARBINARY.
+     */
+    public static final int LONGVARBINARY = -4;
+
+    /**
+     * The type code that identifies the SQL type LONGVARCHAR.
+     */
+    public static final int LONGVARCHAR = -1;
+
+    /**
+     * The type code that identifies the SQL type NULL.
+     */
+    public static final int NULL = 0;
+
+    /**
+     * The type code that identifies the SQL type NUMERIC.
+     */
+    public static final int NUMERIC = 2;
+
+    /**
+     * The type code that identifies that the SQL type is database specific and
+     * is mapped to a Java object, accessed via the methods
+     * <code>getObject</code> and <code>setObject</code>.
+     */
+    public static final int OTHER = 1111;
+
+    /**
+     * The type code that identifies the SQL type REAL.
+     */
+    public static final int REAL = 7;
+
+    /**
+     * The type code that identifies the SQL type REF.
+     */
+    public static final int REF = 2006;
+
+    /**
+     * The type code that identifies the SQL type SMALLINT.
+     */
+    public static final int SMALLINT = 5;
+
+    /**
+     * The type code that identifies the SQL type STRUCT.
+     */
+    public static final int STRUCT = 2002;
+
+    /**
+     * The type code that identifies the SQL type TIME.
+     */
+    public static final int TIME = 92;
+
+    /**
+     * The type code that identifies the SQL type TIMESTAMP.
+     */
+    public static final int TIMESTAMP = 93;
+
+    /**
+     * The type code that identifies the SQL type TINYINT.
+     */
+    public static final int TINYINT = -6;
+
+    /**
+     * The type code that identifies the SQL type VARBINARY.
+     */
+    public static final int VARBINARY = -3;
+
+    /**
+     * The type code that identifies the SQL type VARCHAR.
+     */
+    public static final int VARCHAR = 12;
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java Mon Jun 12 05:13:42 2006
@@ -11,59 +11,61 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.sql;
-
-import java.util.EventObject;
-import java.sql.SQLException;
-import java.io.Serializable;
-
-/**
- * An Event object which is sent when specific events happen on a PooledConnection object.
- * The events involved are when the application closing the PooledConnection and when an error
- * occurs in the PooledConnection.
- * 
- */
-public class ConnectionEvent extends EventObject implements Serializable {
-	
-	private static final long serialVersionUID = -4843217645290030002L;
-	
-	private SQLException theSQLException;
-
-	/**
-	 * Creates a connection event initialized with a supplied PooledConnection.
-	 * @param theConnection the PooledConnection 
-	 */
-	public ConnectionEvent(PooledConnection theConnection ) {
-		super( theConnection );
-		// System.out.println("Clear Connection Event constructor");
-		theSQLException = null;
-	} // end method ConnectionEvent( PooledConnection )
-	
-	/**
-	 * Creates a ConnectionEvent initialized with a supplied PooledConnection and with
-	 * a supplied SQLException indicating that an error has occurred within the PooledConnection.
-	 * @param theConnection the PooledConnection
-	 * @param theException the SQLException holding information about the error that has occurred,
-	 * which is about to be returned to the application.
-	 */
-	public ConnectionEvent(PooledConnection theConnection, SQLException theException ) {
-		super( theConnection );
-		theSQLException = theException;
-	} // end method ConnectionEvent( PooledConnection, SQLException )
-	
-	/**
-	 * Gets the SQLException which holds information about the error which occurred in the
-	 * PooledConnection.
-	 * @return an SQLException containing information about the error. May be null if no error
-	 * has occurred.
-	 */
-	public SQLException getSQLException() {
-		return theSQLException;
-	} // end method getSQLException()
-	
-} // end class ConnectionEvent
-
-
+ */
+
+package javax.sql;
+
+import java.util.EventObject;
+import java.sql.SQLException;
+import java.io.Serializable;
+
+/**
+ * An Event object which is sent when specific events happen on a
+ * PooledConnection object. The events involved are when the application closing
+ * the PooledConnection and when an error occurs in the PooledConnection.
+ */
+public class ConnectionEvent extends EventObject implements Serializable {
+
+    private static final long serialVersionUID = -4843217645290030002L;
+
+    private SQLException theSQLException;
+
+    /**
+     * Creates a connection event initialized with a supplied PooledConnection.
+     * 
+     * @param theConnection
+     *            the PooledConnection
+     */
+    public ConnectionEvent(PooledConnection theConnection) {
+        super(theConnection);
+        theSQLException = null;
+    }
+
+    /**
+     * Creates a ConnectionEvent initialized with a supplied PooledConnection
+     * and with a supplied SQLException indicating that an error has occurred
+     * within the PooledConnection.
+     * 
+     * @param theConnection
+     *            the PooledConnection
+     * @param theException
+     *            the SQLException holding information about the error that has
+     *            occurred, which is about to be returned to the application.
+     */
+    public ConnectionEvent(PooledConnection theConnection,
+            SQLException theException) {
+        super(theConnection);
+        theSQLException = theException;
+    }
+
+    /**
+     * Gets the SQLException which holds information about the error which
+     * occurred in the PooledConnection.
+     * 
+     * @return an SQLException containing information about the error. May be
+     *         null if no error has occurred.
+     */
+    public SQLException getSQLException() {
+        return theSQLException;
+    }
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEventListener.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEventListener.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEventListener.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEventListener.java Mon Jun 12 05:13:42 2006
@@ -11,43 +11,47 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.sql;
-
-import java.util.EventListener;
-
-/**
- * An interface used to receive events generated by a <code>PooledConnection</code>.
- * <p>
- * This interface would typically be implemented by a component which implements Connection
- * Pooling (a Connection Pool Manager).  A Connection will signal events to a ConnectionEventListener
- * either when the application closes a Connection it has been using or when a significant error
- * occurs while the Connection is being used, where the Connection should not be used again.
- * <p>
- * The Connection Pool Manager can return closed Connections to the Pool for later reuse.
- * Connections experiencing an error should be discarded.
- * 
- */
-public interface ConnectionEventListener extends EventListener {
-
-	/**
-	 * Notifies the ConnectionEventListener that an application has called the <code>close</code>
-	 * method on a pooled Connection.
-	 * @param theEvent a ConnectionEvent containing detail about the source of the event.
-	 */
-	public void connectionClosed(ConnectionEvent theEvent);
-	
-	/**
-	 * Notifies the ConnectionEventListener that an error has occurred while a PooledConnection
-	 * was being used and that the PooledConnection can no longer be used for work.  This notification
-	 * is done just before the SQLException passed in the event message is thrown to the application.
-	 * @param theEvent a ConnectionEvent containing detail about the source of the event and the
-	 * SQLException that has occurred.
-	 */
-	public void connectionErrorOccurred(ConnectionEvent theEvent);
-	
-} // end interface ConnectionEventListener
-
-
+ */
+
+package javax.sql;
+
+import java.util.EventListener;
+
+/**
+ * An interface used to receive events generated by a
+ * <code>PooledConnection</code>.
+ * <p>
+ * This interface would typically be implemented by a component which implements
+ * Connection Pooling (a Connection Pool Manager). A Connection will signal
+ * events to a ConnectionEventListener either when the application closes a
+ * Connection it has been using or when a significant error occurs while the
+ * Connection is being used, where the Connection should not be used again.
+ * <p>
+ * The Connection Pool Manager can return closed Connections to the Pool for
+ * later reuse. Connections experiencing an error should be discarded.
+ * 
+ */
+public interface ConnectionEventListener extends EventListener {
+
+    /**
+     * Notifies the ConnectionEventListener that an application has called the
+     * <code>close</code> method on a pooled Connection.
+     * 
+     * @param theEvent
+     *            a ConnectionEvent containing detail about the source of the
+     *            event.
+     */
+    public void connectionClosed(ConnectionEvent theEvent);
+
+    /**
+     * Notifies the ConnectionEventListener that an error has occurred while a
+     * PooledConnection was being used and that the PooledConnection can no
+     * longer be used for work. This notification is done just before the
+     * SQLException passed in the event message is thrown to the application.
+     * 
+     * @param theEvent
+     *            a ConnectionEvent containing detail about the source of the
+     *            event and the SQLException that has occurred.
+     */
+    public void connectionErrorOccurred(ConnectionEvent theEvent);
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionPoolDataSource.java Mon Jun 12 05:13:42 2006
@@ -11,88 +11,111 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.sql;
-
-import java.sql.SQLException;
-import java.io.PrintWriter;
-
-/**
- * An interface for the creation of PooledConnection objects.  Used internally within the package.
- * <p>
- * A class which implements the ConnectionPoolDataSource interface is typically registered with a JNDI
- * naming service directory and is retrieved from there by name.
- * 
- */
-public interface ConnectionPoolDataSource {
-	
-	/**
-	 * Gets the Login Timeout value for this ConnectionPoolDataSource.  The Login Timeout is the maximum time
-	 * in seconds that the ConnectionPoolDataSource will wait when opening a connection to a database. A Timeout
-	 * value of 0 implies either the system default timeout value (if there is one) or that there
-	 * is no timeout.  The default value for the Login Timeout is 0.
-	 * @return the Login Timeout value in seconds.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public int getLoginTimeout() throws SQLException;
-	
-	/**
-	 * Gets the Log Writer for this ConnectionPoolDataSource.
-	 * <p>
-	 * The Log Writer is a stream to which all log and trace messages are sent from this
-	 * ConnectionPoolDataSource. The Log Writer can be null, in which case, log and trace capture is
-	 * disabled.  The default value for the Log Writer when an ConnectionPoolDataSource is created is null.
-	 * Note that the Log Writer for an ConnectionPoolDataSource is not the same as the Log Writer used by
-	 * a <code>DriverManager</code>.
-	 * @return a PrintWriter which is the Log Writer for this ConnectionPoolDataSource. Can be null, in which
-	 * case log writing is disabled for this ConnectionPoolDataSource.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public PrintWriter getLogWriter() throws SQLException;
-	
-	/**
-	 * Create a connection to a database which can then be used as a pooled connection.
-	 * @return a PooledConnection which represents the connection to the database 
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public PooledConnection getPooledConnection() throws SQLException;
-	
-	/**
-	 * Create a connection to a database, using a supplied Username and Password, which can then 
-	 * be used as a pooled connection.
-	 * @param theUser a String containing a User Name for the database
-	 * @param thePassword a String containing the Password for the user identified by 
-	 * <code>theUser</code>
-	 * @return a PooledConnection which represents the connection to the database 
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public PooledConnection getPooledConnection(String theUser, String thePassword) throws SQLException;
-	
-	/**
-	 * Sets the Login Timeout value for this ConnectionPoolDataSource. The Login Timeout is the maximum time
-	 * in seconds that the ConnectionPoolDataSource will wait when opening a connection to a database. A Timeout
-	 * value of 0 implies either the system default timeout value (if there is one) or that there
-	 * is no timeout.  The default value for the Login Timeout is 0.
-	 * @param theTimeout the new Login Timeout value in seconds.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public void setLoginTimeout(int theTimeout) throws SQLException;
-	
-	/**
-	 * Sets the Log Writer for this ConnectionPoolDataSource.
-	 * <p>
-	 * The Log Writer is a stream to which all log and trace messages are sent from this
-	 * ConnectionPoolDataSource. The Log Writer can be null, in which case, log and trace capture is
-	 * disabled.  The default value for the Log Writer when an ConnectionPoolDataSource is created is null.
-	 * Note that the Log Writer for an ConnectionPoolDataSource is not the same as the Log Writer used by
-	 * a <code>DriverManager</code>.
-	 * @param theWriter a PrintWriter to use as the Log Writer for this ConnectionPoolDataSource.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public void setLogWriter(PrintWriter theWriter) throws SQLException;
-
-} // end interface ConnectionPoolDataSource
-
-
+ */
+
+package javax.sql;
+
+import java.sql.SQLException;
+import java.io.PrintWriter;
+
+/**
+ * An interface for the creation of PooledConnection objects. Used internally
+ * within the package.
+ * <p>
+ * A class which implements the ConnectionPoolDataSource interface is typically
+ * registered with a JNDI naming service directory and is retrieved from there
+ * by name.
+ */
+public interface ConnectionPoolDataSource {
+
+    /**
+     * Gets the Login Timeout value for this ConnectionPoolDataSource. The Login
+     * Timeout is the maximum time in seconds that the ConnectionPoolDataSource
+     * will wait when opening a connection to a database. A Timeout value of 0
+     * implies either the system default timeout value (if there is one) or that
+     * there is no timeout. The default value for the Login Timeout is 0.
+     * 
+     * @return the Login Timeout value in seconds.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public int getLoginTimeout() throws SQLException;
+
+    /**
+     * Gets the Log Writer for this ConnectionPoolDataSource.
+     * <p>
+     * The Log Writer is a stream to which all log and trace messages are sent
+     * from this ConnectionPoolDataSource. The Log Writer can be null, in which
+     * case, log and trace capture is disabled. The default value for the Log
+     * Writer when an ConnectionPoolDataSource is created is null. Note that the
+     * Log Writer for an ConnectionPoolDataSource is not the same as the Log
+     * Writer used by a <code>DriverManager</code>.
+     * 
+     * @return a PrintWriter which is the Log Writer for this
+     *         ConnectionPoolDataSource. Can be null, in which case log writing
+     *         is disabled for this ConnectionPoolDataSource.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public PrintWriter getLogWriter() throws SQLException;
+
+    /**
+     * Create a connection to a database which can then be used as a pooled
+     * connection.
+     * 
+     * @return a PooledConnection which represents the connection to the
+     *         database
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public PooledConnection getPooledConnection() throws SQLException;
+
+    /**
+     * Create a connection to a database, using a supplied Username and
+     * Password, which can then be used as a pooled connection.
+     * 
+     * @param theUser
+     *            a String containing a User Name for the database
+     * @param thePassword
+     *            a String containing the Password for the user identified by
+     *            <code>theUser</code>
+     * @return a PooledConnection which represents the connection to the
+     *         database
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public PooledConnection getPooledConnection(String theUser,
+            String thePassword) throws SQLException;
+
+    /**
+     * Sets the Login Timeout value for this ConnectionPoolDataSource. The Login
+     * Timeout is the maximum time in seconds that the ConnectionPoolDataSource
+     * will wait when opening a connection to a database. A Timeout value of 0
+     * implies either the system default timeout value (if there is one) or that
+     * there is no timeout. The default value for the Login Timeout is 0.
+     * 
+     * @param theTimeout
+     *            the new Login Timeout value in seconds.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public void setLoginTimeout(int theTimeout) throws SQLException;
+
+    /**
+     * Sets the Log Writer for this ConnectionPoolDataSource.
+     * <p>
+     * The Log Writer is a stream to which all log and trace messages are sent
+     * from this ConnectionPoolDataSource. The Log Writer can be null, in which
+     * case, log and trace capture is disabled. The default value for the Log
+     * Writer when an ConnectionPoolDataSource is created is null. Note that the
+     * Log Writer for an ConnectionPoolDataSource is not the same as the Log
+     * Writer used by a <code>DriverManager</code>.
+     * 
+     * @param theWriter
+     *            a PrintWriter to use as the Log Writer for this
+     *            ConnectionPoolDataSource.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public void setLogWriter(PrintWriter theWriter) throws SQLException;
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/DataSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/DataSource.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/DataSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/DataSource.java Mon Jun 12 05:13:42 2006
@@ -11,108 +11,126 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.sql;
-
-import java.sql.SQLException;
-import java.sql.Connection;
-import java.io.PrintWriter;
-
-/**
- * An interface for the creation of Connection objects which represent a connection to a
- * database.  This interface is an alternative to the <code>java.sql.DriverManager</code>.
- * <p>
- * A class which implements the DataSource interface is typically registered with a JNDI
- * naming service directory and is retrieved from there by name.
- * <p>
- * The DataSource interface is typically implemented by the writer of a JDBC driver.  There
- * are three variants of the DataSource interface, which produce Connections with differing
- * characteristics:
- * <ol>
- * <li>Standard DataSource, which produces standard Connection objects with no special features.</li>
- * <li>Connection Pool DataSource, which produces PooledConnection objects which are able to
- * participate in connection pooling, typically involving a connection pooling manager as an
- * intermediary between applications and the database.</li>
- * <li>Distributed transaction DataSource ("XADataSource"), which produces XAConnection objects
- * which can be used to handle distributed transactions and which typically involve a transaction
- * manager component in the system.  XAConnection objects also typically provide connection
- * pooling capabilities as well as distributed transaction capabilities. </li>
- * </ol>
- * <p>
- * Note that a JDBC driver which is accessed via the DataSource interface is loaded via a JNDI
- * lookup process.  A driver loaded in this way does not register itself with the 
- * <code>DriverManager</code>.
- * 
- */
-public interface DataSource {
-	
-	/**
-	 * Creates a connection to the database represented by this DataSource. 
-	 * @return a Connection object which is a connection to the database.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public Connection getConnection() throws SQLException;
-	
-	/**
-	 * Creates a connection to the database represented by this DataSource, using a supplied 
-	 * Username and Password,. 
-	 * @param theUsername a String containing a User Name for the database
-	 * @param thePassword  a String containing the Password for the user identified by 
-	 * <code>theUsername</code>
-	 * @return a Connection object which is a connection to the database.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public Connection getConnection(String theUsername, String thePassword) throws SQLException;
-
-	/**
-	 * Gets the Login Timeout value for this DataSource.  The Login Timeout is the maximum time
-	 * in seconds that the DataSource will wait when opening a connection to a database. A Timeout
-	 * value of 0 implies either the system default timeout value (if there is one) or that there
-	 * is no timeout.  The default value for the Login Timeout is 0.
-	 * @return the Login Timeout value in seconds.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public int getLoginTimeout() throws SQLException;
-	
-	/**
-	 * Gets the Log Writer for this DataSource.
-	 * <p>
-	 * The Log Writer is a stream to which all log and trace messages are sent from this
-	 * DataSource. The Log Writer can be null, in which case, log and trace capture is
-	 * disabled.  The default value for the Log Writer when an DataSource is created is null.
-	 * Note that the Log Writer for an DataSource is not the same as the Log Writer used by
-	 * a <code>DriverManager</code>.
-	 * @return a PrintWriter which is the Log Writer for this DataSource. Can be null, in which
-	 * case log writing is disabled for this DataSource.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public PrintWriter getLogWriter() throws SQLException;
-	
-	/**
-	 * Sets the Login Timeout value for this DataSource. The Login Timeout is the maximum time
-	 * in seconds that the DataSource will wait when opening a connection to a database. A Timeout
-	 * value of 0 implies either the system default timeout value (if there is one) or that there
-	 * is no timeout.  The default value for the Login Timeout is 0.
-	 * @param theTimeout the new Login Timeout value in seconds.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public void setLoginTimeout( int theTimeout ) throws SQLException;
-	
-	/**
-	 * Sets the Log Writer for this DataSource.
-	 * <p>
-	 * The Log Writer is a stream to which all log and trace messages are sent from this
-	 * DataSource. The Log Writer can be null, in which case, log and trace capture is
-	 * disabled.  The default value for the Log Writer when an DataSource is created is null.
-	 * Note that the Log Writer for an DataSource is not the same as the Log Writer used by
-	 * a <code>DriverManager</code>.
-	 * @param theWriter a PrintWriter to use as the Log Writer for this DataSource.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public void setLogWriter(PrintWriter theWriter) throws SQLException;
-	
-} // end interface DataSource
-
-
+ */
+
+package javax.sql;
+
+import java.sql.SQLException;
+import java.sql.Connection;
+import java.io.PrintWriter;
+
+/**
+ * An interface for the creation of Connection objects which represent a
+ * connection to a database. This interface is an alternative to the
+ * <code>java.sql.DriverManager</code>.
+ * <p>
+ * A class which implements the DataSource interface is typically registered
+ * with a JNDI naming service directory and is retrieved from there by name.
+ * <p>
+ * The DataSource interface is typically implemented by the writer of a JDBC
+ * driver. There are three variants of the DataSource interface, which produce
+ * Connections with differing characteristics:
+ * <ol>
+ * <li>Standard DataSource, which produces standard Connection objects with no
+ * special features.</li>
+ * <li>Connection Pool DataSource, which produces PooledConnection objects
+ * which are able to participate in connection pooling, typically involving a
+ * connection pooling manager as an intermediary between applications and the
+ * database.</li>
+ * <li>Distributed transaction DataSource ("XADataSource"), which produces
+ * XAConnection objects which can be used to handle distributed transactions and
+ * which typically involve a transaction manager component in the system.
+ * XAConnection objects also typically provide connection pooling capabilities
+ * as well as distributed transaction capabilities. </li>
+ * </ol>
+ * <p>
+ * Note that a JDBC driver which is accessed via the DataSource interface is
+ * loaded via a JNDI lookup process. A driver loaded in this way does not
+ * register itself with the <code>DriverManager</code>.
+ */
+public interface DataSource {
+
+    /**
+     * Creates a connection to the database represented by this DataSource.
+     * 
+     * @return a Connection object which is a connection to the database.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public Connection getConnection() throws SQLException;
+
+    /**
+     * Creates a connection to the database represented by this DataSource,
+     * using a supplied Username and Password,.
+     * 
+     * @param theUsername
+     *            a String containing a User Name for the database
+     * @param thePassword
+     *            a String containing the Password for the user identified by
+     *            <code>theUsername</code>
+     * @return a Connection object which is a connection to the database.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public Connection getConnection(String theUsername, String thePassword)
+            throws SQLException;
+
+    /**
+     * Gets the Login Timeout value for this DataSource. The Login Timeout is
+     * the maximum time in seconds that the DataSource will wait when opening a
+     * connection to a database. A Timeout value of 0 implies either the system
+     * default timeout value (if there is one) or that there is no timeout. The
+     * default value for the Login Timeout is 0.
+     * 
+     * @return the Login Timeout value in seconds.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public int getLoginTimeout() throws SQLException;
+
+    /**
+     * Gets the Log Writer for this DataSource.
+     * <p>
+     * The Log Writer is a stream to which all log and trace messages are sent
+     * from this DataSource. The Log Writer can be null, in which case, log and
+     * trace capture is disabled. The default value for the Log Writer when an
+     * DataSource is created is null. Note that the Log Writer for an DataSource
+     * is not the same as the Log Writer used by a <code>DriverManager</code>.
+     * 
+     * @return a PrintWriter which is the Log Writer for this DataSource. Can be
+     *         null, in which case log writing is disabled for this DataSource.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public PrintWriter getLogWriter() throws SQLException;
+
+    /**
+     * Sets the Login Timeout value for this DataSource. The Login Timeout is
+     * the maximum time in seconds that the DataSource will wait when opening a
+     * connection to a database. A Timeout value of 0 implies either the system
+     * default timeout value (if there is one) or that there is no timeout. The
+     * default value for the Login Timeout is 0.
+     * 
+     * @param theTimeout
+     *            the new Login Timeout value in seconds.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public void setLoginTimeout(int theTimeout) throws SQLException;
+
+    /**
+     * Sets the Log Writer for this DataSource.
+     * <p>
+     * The Log Writer is a stream to which all log and trace messages are sent
+     * from this DataSource. The Log Writer can be null, in which case, log and
+     * trace capture is disabled. The default value for the Log Writer when an
+     * DataSource is created is null. Note that the Log Writer for an DataSource
+     * is not the same as the Log Writer used by a <code>DriverManager</code>.
+     * 
+     * @param theWriter
+     *            a PrintWriter to use as the Log Writer for this DataSource.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public void setLogWriter(PrintWriter theWriter) throws SQLException;
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/PooledConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/PooledConnection.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/PooledConnection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/PooledConnection.java Mon Jun 12 05:13:42 2006
@@ -11,84 +11,99 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
-
-
-package javax.sql;
-
-import java.sql.SQLException;
-import java.sql.Connection;
-
-/**
- * An interface which provides facilities for handling connections to a database which are pooled.
- * <p>
- * Typically, a PooledConnection is recycled when it is no longer required by an application, 
- * rather than being closed and discarded.  The reason for treating connections in this way is that
- * it can be an expensive process both to establish a connection to a database and to destroy
- * the connection.  Reusing connections through a pool is a way of improving system performance
- * and reducing overhead.
- * <p>
- * It is not intended that an application use the PooledConnection interface directly.  The 
- * PooledConnection interface is intended for use by a component called a Connection Pool
- * Manager, typically part of the infrastructure that supports use of the database by applications.
- * <p>
- * Applications obtain connections to the database by calling the <code>DataSource.getConnection</code> 
- * method.  Under the covers, the Connection Pool Manager will get a PooledConnection object from
- * its connection pool and passes back a Connection object that wraps or references the 
- * PooledConnection object.  A new PooledConnection object will only be created if the pool is
- * empty.
- * <p>
- * When the application is finished using a PooledConnection, the application calls the 
- * <code>Connection.close</code> method. The Connection Pool Manager is notified via a
- * ConnectionEvent from the Connection that this has happened (the Pool Manager registers itself
- * with the Connection before the Connection is given to the application). The Pool Manager
- * removes the underlying PooledConnection object from the Connection and returns it to the pool
- * for reuse - the PooledConnection is thus recycled rather than being destroyed.
- * <p>
- * The connection to the database represented by the PooledConnection is kept open until the
- * PooledConnection object itself is deactivated by the Connection Pool Manager, which calls the
- * <code>PooledConnection.close</code> method.  This is typically done if there are too many
- * inactive connections in the pool, if the PooledConnection encounters a problem that makes it
- * unusable or if the whole system is being shut down. 
- * 
- */
-public interface PooledConnection {
-
-	/**
-	 * Registers the supplied ConnectionEventListener with this PooledConnection.  Once registered,
-	 * the ConnectionEventListener will receive ConnectionEvent events when they occur in the 
-	 * PooledConnection.
-	 * @param theListener an object which implements the ConnectionEventListener interface.
-	 */
-	public void addConnectionEventListener(ConnectionEventListener theListener);
-	
-	/**
-	 * Closes the connection to the database held by this PooledConnection. This method should not
-	 * be called directly by application code - it is intended for use by the Connection Pool
-	 * manager component.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public void close() throws SQLException;
-	
-	/**
-	 * Creates a connection to the database.  This method is typically called by the Connectio
-	 * Pool manager when an application invokes the method <code>DataSource.getConnection</code>
-	 * and there are no PooledConnection objects available in the connection pool.
-	 * @return a Connection object that is a handle to this PooledConnection object.
-	 * @throws SQLException if there is a problem accessing the database.
-	 */
-	public Connection getConnection() throws SQLException;
-	
-	/**
-	 * Deregister the supplied ConnectionEventListener from this PooledConnection.  Once
-	 * deregistered, the ConnectionEventListener will not longer receive events ocurring in the
-	 * PooledConnection. 
-	 * @param theListener an object which implements the ConnectionEventListener interface. This
-	 * object should have previously been registered with the PooledConnection using the 
-	 * <code>addConnectionEventListener</code> method.
-	 */
-	public void removeConnectionEventListener(ConnectionEventListener theListener);
-	
-} // end interface PooledConnection
-
-
+ */
+
+package javax.sql;
+
+import java.sql.SQLException;
+import java.sql.Connection;
+
+/**
+ * An interface which provides facilities for handling connections to a database
+ * which are pooled.
+ * <p>
+ * Typically, a PooledConnection is recycled when it is no longer required by an
+ * application, rather than being closed and discarded. The reason for treating
+ * connections in this way is that it can be an expensive process both to
+ * establish a connection to a database and to destroy the connection. Reusing
+ * connections through a pool is a way of improving system performance and
+ * reducing overhead.
+ * <p>
+ * It is not intended that an application use the PooledConnection interface
+ * directly. The PooledConnection interface is intended for use by a component
+ * called a Connection Pool Manager, typically part of the infrastructure that
+ * supports use of the database by applications.
+ * <p>
+ * Applications obtain connections to the database by calling the
+ * <code>DataSource.getConnection</code> method. Under the covers, the
+ * Connection Pool Manager will get a PooledConnection object from its
+ * connection pool and passes back a Connection object that wraps or references
+ * the PooledConnection object. A new PooledConnection object will only be
+ * created if the pool is empty.
+ * <p>
+ * When the application is finished using a PooledConnection, the application
+ * calls the <code>Connection.close</code> method. The Connection Pool Manager
+ * is notified via a ConnectionEvent from the Connection that this has happened
+ * (the Pool Manager registers itself with the Connection before the Connection
+ * is given to the application). The Pool Manager removes the underlying
+ * PooledConnection object from the Connection and returns it to the pool for
+ * reuse - the PooledConnection is thus recycled rather than being destroyed.
+ * <p>
+ * The connection to the database represented by the PooledConnection is kept
+ * open until the PooledConnection object itself is deactivated by the
+ * Connection Pool Manager, which calls the <code>PooledConnection.close</code>
+ * method. This is typically done if there are too many inactive connections in
+ * the pool, if the PooledConnection encounters a problem that makes it unusable
+ * or if the whole system is being shut down.
+ * 
+ */
+public interface PooledConnection {
+
+    /**
+     * Registers the supplied ConnectionEventListener with this
+     * PooledConnection. Once registered, the ConnectionEventListener will
+     * receive ConnectionEvent events when they occur in the PooledConnection.
+     * 
+     * @param theListener
+     *            an object which implements the ConnectionEventListener
+     *            interface.
+     */
+    public void addConnectionEventListener(ConnectionEventListener theListener);
+
+    /**
+     * Closes the connection to the database held by this PooledConnection. This
+     * method should not be called directly by application code - it is intended
+     * for use by the Connection Pool manager component.
+     * 
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public void close() throws SQLException;
+
+    /**
+     * Creates a connection to the database. This method is typically called by
+     * the Connectio Pool manager when an application invokes the method
+     * <code>DataSource.getConnection</code> and there are no PooledConnection
+     * objects available in the connection pool.
+     * 
+     * @return a Connection object that is a handle to this PooledConnection
+     *         object.
+     * @throws SQLException
+     *             if there is a problem accessing the database.
+     */
+    public Connection getConnection() throws SQLException;
+
+    /**
+     * Deregister the supplied ConnectionEventListener from this
+     * PooledConnection. Once deregistered, the ConnectionEventListener will not
+     * longer receive events ocurring in the PooledConnection.
+     * 
+     * @param theListener
+     *            an object which implements the ConnectionEventListener
+     *            interface. This object should have previously been registered
+     *            with the PooledConnection using the
+     *            <code>addConnectionEventListener</code> method.
+     */
+    public void removeConnectionEventListener(
+            ConnectionEventListener theListener);
+}