harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r386087 [37/45] - in /incubator/harmony/enhanced/classlib/trunk: make/ make/patternsets/ modules/jndi/ modules/jndi/META-INF/ modules/jndi/make/ modules/jndi/make/common/ modules/jndi/src/ modules/jndi/src/main/ modules/jndi/src/main/java/ ...
Date Wed, 15 Mar 2006 14:57:17 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,195 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+import java.text.SimpleDateFormat;
+import java.lang.IllegalArgumentException;
+import java.text.ParseException;
+import java.io.Serializable;
+
+/**
+ * A Date class which can consume and produce dates in SQL Date format.
+ * <p>
+ * The SQL date format represents a date as yyyy-mm-dd.  Note that this date format only deals with year, month
+ * and day values.  There are no values for hours, minutes, seconds.
+ * <p>
+ * This contrasts with regular java.util.Date values, which include time values for hours, minutes, seconds,
+ * milliseconds.
+ * <p>
+ * Time points are handled as millisecond values - milliseconds since the epoch, January 1st 1970, 
+ * 00:00:00.000 GMT.  Time values passed to the java.sql.Date class are "normalised" to the time 
+ * 00:00:00.000 GMT on the date implied by the time value.
+ */
+public class Date extends java.util.Date implements Serializable, Cloneable, Comparable {
+
+	private static final long serialVersionUID = 1511598038487230103L;
+	
+	/**
+	 * @deprecated Please use the constructor Date( long )
+	 * Constructs a Date object corresponding to the supplied Year, Month and Day. 
+	 * @param theYear the year, specified as the year minus 1900.  Must be in the range 0 to 8099.
+	 * @param theMonth the month, specified as a number with 0 = January.  Must be in the range 0 to 11.
+	 * @param theDay the day in the month.  Must be in the range 1 to 31.
+	 */
+	public Date( int theYear, int theMonth, int theDay ) {
+		super( theYear, theMonth, theDay );
+	} // end method Date(int, int, int )
+	
+	/**
+	 * Creates a Date which corresponds to the day implied by the supplied theDate milliseconds 
+	 * time value.
+	 * 
+	 * @param theDate - a time value in milliseconds since the epoch - January 1 1970 00:00:00 GMT. 
+	 * The time value (hours, minutes, seconds, milliseconds) stored in the Date object is adjusted 
+	 * to correspond to 00:00:00 GMT on the day implied by the supplied time value. 
+	 */
+	public Date( long theDate ) {
+		super( normalizeTime( theDate ) );
+		// System.out.println("Clear version of java.sql.Date");
+	} // end method Date( long )
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have an hours component.
+	 * @return 0
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public int getHours() {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+		return 0;
+	} // end method getHours
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have a minutes component.
+	 * @return 0
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public int getMinutes() {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+		return 0;
+	} // end method getMinutes()
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have a seconds component.
+	 * @return 0
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public int getSeconds() {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+		return 0;
+	} // end method getSeconds
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have an hours component.
+	 * @param theHours the number of hours to set
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public void setHours( int theHours ) {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+	} // end method setHours( int )
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have a minutes component.
+	 * @param theMinutes the number of minutes to set
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public void setMinutes( int theMinutes ) {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+	} // end method setMinutes( int )
+	
+	/**
+	 * @deprecated
+	 * This method is deprecated and must not be used.  SQL Date values do not have a seconds component.
+	 * @param theSeconds the number of seconds to set
+	 * @throws IllegalArgumentException if this method is called
+	 */
+	public void setSeconds( int theSeconds ) {
+		if( true ) {
+			throw new IllegalArgumentException();
+		} // end if
+	} // end method setHours( int )
+	
+	/**
+	 * Sets this date to a date supplied as a milliseconds value.  The date is set based
+	 * on the supplied time value after removing any time elements finer than a day, based 
+	 * on zero GMT for that day. 
+	 * @param theTime the time in milliseconds since the Epoch
+	 */
+	public void setTime( long theTime ) {
+		// Store the Date based on the supplied time after removing any time elements
+		// finer than the day based on zero GMT
+		super.setTime( normalizeTime( theTime ) );
+	} // end method setTime( int )
+	
+	/**
+	 * Produces a string representation of the Date in SQL format
+	 * @return a string representation of the Date in SQL format - "yyyy-mm-dd".
+	 */
+	public String toString() {
+		SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" ); //$NON-NLS-1$
+		
+		return dateFormat.format( this );
+	} // end method toString()
+	
+	/**
+	 * Creates a Date from a string representation of a date in SQL format.
+	 * @param theString the string representation of a date in SQL format - "yyyy-mm-dd".
+	 * @return the Date object 
+	 * @throws IllegalArgumentException if the format of the supplied string does not match the
+	 * SQL format.
+	 */
+	public static Date valueOf( String theString ) {
+		java.util.Date aDate;
+		
+		if( theString == null ) throw new IllegalArgumentException();
+		
+		SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" ); //$NON-NLS-1$
+		try {
+			aDate = dateFormat.parse( theString );
+		} catch( ParseException pe ) {
+			throw new IllegalArgumentException();
+		} // end try
+		
+		return new Date( aDate.getTime() );
+	} // end valueOf( String ) 
+
+	/*
+	 * Private method which normalizes a Time value, removing all low significance
+	 * digits corresponding to milliseconds, seconds, minutes and hours, so that the
+	 * returned Time value corresponds to 00:00:00 GMT on a particular day.
+	 *
+	 */
+	private static long normalizeTime( long theTime ) {
+		return theTime;
+	} // end method normalizeTime( long )
+} /* end class Date */
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,92 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+import java.util.Properties;
+
+/**
+ * An Interface to a JDBC Driver.
+ * <p>
+ * The JDBC Driver uses URLs to specify the location of specific data.  URL format typically takes the form
+ * "xxxx:yyyy:SpecificData", where "xxxx:yyyy" is termed the subprotocol and is normally the same for 
+ * all uses of a particular driver. "SpecificData" is a string which identifies the particular data
+ * source that the driver should use. 
+ * 
+ */
+public interface Driver {
+
+	/**
+	 * Returns whether the driver thinks that it can open a connection to the given URL.
+	 * @param url the URL to connect to.
+	 * @return true if the driver thinks that is can open a connection to the supplied URL,  
+	 * flase otherwise. Typically, the driver will respond true if it thinks that it can handle 
+	 * the subprotocol specified by the driver.
+	 * @throws SQLException
+	 */
+	public boolean 	acceptsURL(String url) throws SQLException;
+    
+	/**
+	 * Attempts to make a database connection to a datasource specified by a supplied URL.
+	 * @param url the url to connect.
+	 * @param info some properties that should be used in establishing the connection.  The properties
+	 * consist of name/value pairs of Strings.  Normally, a connection to a database requires at least
+	 * two properties - for "user" and "password" in order to pass authentication to the database. 
+	 * @return a Connection object representing the connection to the database.
+	 * @throws SQLException if a database error occurs
+	 */
+	public Connection 	connect(String url, Properties info) throws SQLException;
+    
+	/**
+	 * Gets the driver's major version number.
+	 * @return the major version number of the Driver - typically starts at 1.
+	 */
+	public int 	getMajorVersion();
+    
+	/**
+	 * Gets the driver's minor version number.
+	 * @return the minor version number of the Driver - typically starts at 0.
+	 */
+	public int 	getMinorVersion();
+    
+	/**
+	 * Gets information about possible properties for this driver.
+	 * <p>
+	 * This method is intended to provide a listing of possible properties that the user of
+	 * the driver may need to supply in order to correct connect to a database.  Note that the
+	 * returned array of Properties may change depending on the supplied list of property values.
+	 * @param url the url of the database.  A using program may call this method iteratively 
+	 * as the property list is built up - for example, when displaying a dialog to an end-user
+	 * as part of the database login process.
+	 * @param info
+	 * @return an array of DriverPropertyInfo records which provide detail on each property that
+	 * the driver will accept.
+	 * @throws SQLException
+	 */
+	public DriverPropertyInfo[] 	getPropertyInfo(String url, Properties info) throws SQLException;
+    
+	/**
+	 * Reports whether this driver is a genuine JDBC CompliantTM driver.  The driver may only return
+	 * true from this method if it passes all the JDBC Compliance tests.
+	 * <p>
+	 * A driver may not be fully compliant if the underlying database has limited functionality.
+	 * @return true if the driver is fully JDBC compliant, false otherwise.
+	 */
+	public boolean 	jdbcCompliant();
+    
+} // end interface Driver
+
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,396 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+import java.util.Properties;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Vector;
+import com.ibm.common.ClassUtils;
+import com.ibm.oti.vm.VM;
+
+/**
+ * Provides facilities for managing JDBC Drivers.
+ * <p>
+ * The DriverManager class will load JDBC drivers during its initialization,
+ * from the list of drivers referenced by the System Property "jdbc.drivers".
+ * 
+ */
+public class DriverManager {
+
+	// Facilities for logging. The Print Stream is deprecated but is maintained
+	// here for compatibility.
+	private static PrintStream thePrintStream = null;
+
+	private static PrintWriter thePrintWriter = null;
+
+	// Login timeout value - by default set to 0 -> "wait forever"
+	private static int loginTimeout = 0;
+
+	// Set to hold Registered Drivers - initial capacity 10 drivers (will expand
+	// automatically
+	// if necessary.
+	private static HashSet theDriverSet = new HashSet(10);
+
+	// Permission for setting log
+	private static SQLPermission logPermission = new SQLPermission("setLog"); //$NON-NLS-1$
+
+	/*
+	 * Load drivers on initialization
+	 */
+	static {
+		// System.out.println("Clear version of java.sql.DriverManager loaded")
+		// ;
+		loadInitialDrivers();
+	} // end static initializer
+
+	/*
+	 * Loads the set of JDBC drivers defined by the Property "jdbc.drivers" if
+	 * it is defined.
+	 */
+	private static void loadInitialDrivers() {
+		String theDriverList = System.getProperty("jdbc.drivers", null); //$NON-NLS-1$
+		if (theDriverList == null)
+			return;
+
+		// System.out.println( "Loading initial drivers: " + theDriverList );
+
+		// Get the names of the drivers as an array of Strings from the system
+		// property by
+		// splitting the property at the separator character ':'
+		String[] theDriverNames = theDriverList.split(":"); //$NON-NLS-1$
+
+		for (int i = 0; i < theDriverNames.length; i++) {
+			// System.out.println( "Driver: " + (i + 1) + " " +
+			// theDriverNames[i] );
+
+			try {
+				// Load the driver class
+				Class.forName(theDriverNames[i], true, ClassLoader
+						.getSystemClassLoader());
+			} catch (ClassNotFoundException e) {
+				// System.out.println("DriverManager: Unable to load driver: " +
+				// theDriverNames[i] );
+			} catch (Throwable t) {
+				// System.out.println("DriverManager: Exception loading driver:
+				// " + theDriverNames[i] );
+				// t.getMessage();
+				// t.printStackTrace();
+			} // end try
+		} // end for
+
+	} // end method loadInitialDrivers()
+
+	/*
+	 * A private constructor to prevent allocation
+	 */
+	private DriverManager() {
+		super();
+	} // end method DriverManager()
+
+	/**
+	 * Removes a driver from the DriverManager's registered driver list. This
+	 * will only succeed where the caller's classloader loaded the driver that
+	 * is to be removed. If the driver was loaded by a different classloader,
+	 * the removal of the driver will fail silently.
+	 * <p>
+	 * If the removal succeeds, the DriverManager will not in future use this
+	 * driver when asked to get a Connection.
+	 * 
+	 * @param driver
+	 * @throws SQLException
+	 *             if there is an exception accessing the database.
+	 */
+	public static void deregisterDriver(Driver driver) throws SQLException {
+		if (driver == null)
+			return;
+		ClassLoader callerClassLoader = VM.callerClassLoader();
+
+		if (!ClassUtils.isClassFromClassLoader(driver, callerClassLoader)) {
+			throw new SecurityException(
+					"DriverManager: calling class not authorized to deregister JDBC driver");
+		} // end if
+		synchronized (theDriverSet) {
+			theDriverSet.remove(driver);
+		} // end synchronized
+
+	} // end method deregisterDriver( Driver );
+
+	/**
+	 * Attempts to establish a connection to the given database URL.
+	 * 
+	 * @param url
+	 *            a URL string representing the database target to connect with
+	 * @return a Connection to the database identified by the URL. null if no
+	 *         connection can be made.
+	 * @throws SQLException
+	 *             if there is an error while attempting to connect to the
+	 *             database identified by the URL
+	 */
+	public static Connection getConnection(String url) throws SQLException {
+		// Call the getConnection method with an empty Properties parameter
+		return getConnection(url, new Properties());
+	} // end method getConnection( String )
+
+	/**
+	 * Attempts to establish a connection to the given database URL.
+	 * 
+	 * @param url
+	 *            a URL string representing the database target to connect with
+	 * @param info
+	 *            a set of Properties to use as arguments to set up the
+	 *            connection. Properties are arbitrary string/value pairs.
+	 *            Normally, at least the properties "user" and "password" should
+	 *            be passed, with appropriate settings for the userid and its
+	 *            corresponding password to get access to the database
+	 *            concerned.
+	 * @return a Connection to the database identified by the URL. null if no
+	 *         connection can be made.
+	 * @throws SQLException
+	 *             if there is an error while attempting to connect to the
+	 *             database identified by the URL
+	 */
+	public static Connection getConnection(String url, Properties info)
+			throws SQLException {
+		if (url == null)
+			throw new SQLException("The url cannot be null");
+		synchronized (theDriverSet) {
+			// Loop over the drivers in the DriverSet checking to see if one can
+			// open a
+			// connection to the supplied URL - return the first connection
+			// which is returned
+			Iterator theIterator = theDriverSet.iterator();
+			while (theIterator.hasNext()) {
+				Driver theDriver = (Driver) theIterator.next();
+				Connection theConnection = theDriver.connect(url, info);
+				if (theConnection != null)
+					return theConnection;
+			} // end while
+		} // end synchronized
+		// If we get here, none of the drivers are able to resolve the URL
+		throw new SQLException("No suitable driver");
+	} // end method getConnection( String, Properties )
+
+	/**
+	 * Attempts to establish a connection to the given database URL.
+	 * 
+	 * @param url
+	 *            a URL string representing the database target to connect with
+	 * @param user
+	 *            a userid used to login to the database
+	 * @param password
+	 *            a password for the userid to login to the database
+	 * @return a Connection to the database identified by the URL. null if no
+	 *         connection can be made.
+	 * @throws SQLException
+	 *             if there is an error while attempting to connect to the
+	 *             database identified by the URL
+	 */
+	public static Connection getConnection(String url, String user,
+			String password) throws SQLException {
+		if (user == null || password == null) {
+			throw new SQLException("Userid and/or password not supplied");
+		} // end if
+		Properties theProperties = new Properties();
+		theProperties.setProperty("user", user); //$NON-NLS-1$
+		theProperties.setProperty("password", password); //$NON-NLS-1$
+		return getConnection(url, theProperties);
+	} // end method getConnection( String, String, String )
+
+	/**
+	 * Tries to find a driver that can interpret the supplied URL.
+	 * 
+	 * @param url
+	 *            the URL of a database
+	 * @return a Driver that can understand the given URL. null if no Driver
+	 *         understands the URL
+	 * @throws SQLException
+	 *             if there is any kind of Database Access problem
+	 */
+	public static Driver getDriver(String url) throws SQLException {
+		ClassLoader callerClassLoader = VM.callerClassLoader();
+
+		synchronized (theDriverSet) {
+			// Loop over the drivers in the DriverSet checking to see if one
+			// does
+			// understand the supplied URL - return the first driver which does
+			// understand
+			// the URL
+			Iterator theIterator = theDriverSet.iterator();
+			while (theIterator.hasNext()) {
+				Driver theDriver = (Driver) theIterator.next();
+				if (theDriver.acceptsURL(url)
+						&& ClassUtils.isClassFromClassLoader(theDriver,
+								callerClassLoader))
+					return theDriver;
+			} // end while
+		} // end synchronized
+		// If no drivers understand the URL, throw an SQLException
+		throw new SQLException("No suitable driver");
+	} // end method getDriver( String )
+
+	/**
+	 * Returns an Enumeration that contains all of the loaded JDBC drivers that
+	 * the current caller can access.
+	 * 
+	 * @return An Enumeration containing all the currently loaded JDBC Drivers
+	 */
+	public static Enumeration getDrivers() {
+		Enumeration theEnumeration;
+
+		ClassLoader callerClassLoader = VM.callerClassLoader();
+		// Synchronize to avoid clashes with additions and removals of drivers
+		// in the
+		// DriverSet
+		synchronized (theDriverSet) {
+			// Create the Enumeration by building a Vector from the elements of
+			// the
+			// DriverSet
+			Vector theVector = new Vector();
+			Iterator theIterator = theDriverSet.iterator();
+			while (theIterator.hasNext()) {
+				Driver theDriver = (Driver) theIterator.next();
+				if (ClassUtils.isClassFromClassLoader(theDriver,
+						callerClassLoader)) {
+					theVector.add(theDriver);
+				} // end if
+			} // end for
+			theEnumeration = theVector.elements();
+		} // end synchronized
+		return theEnumeration;
+	} // end method getDrivers()
+
+	/**
+	 * Returns the login timeout when connecting to a database, in seconds.
+	 * 
+	 * @return the login timeout in seconds
+	 */
+	public static int getLoginTimeout() {
+		return loginTimeout;
+	} // end method getLoginTimeout()
+
+	/**
+	 * @deprecated Gets the log PrintStream used by the DriverManager and all
+	 *             the JDBC Drivers.
+	 * @return the PrintStream used for logging activity
+	 */
+	public static PrintStream getLogStream() {
+		return thePrintStream;
+	} // end method getLogStream()
+
+	/**
+	 * Retrieves the log writer.
+	 * 
+	 * @return A PrintWriter object used as the log writer. null if no log
+	 *         writer is set.
+	 */
+	public static PrintWriter getLogWriter() {
+		return thePrintWriter;
+	} // end method getLogWriter()
+
+	/**
+	 * Prints a message to the current JDBC log stream. This is either the
+	 * PrintWriter or (deprecated) the PrintStream, if set.
+	 * 
+	 * @param message
+	 *            the message to print to the JDBC log stream
+	 */
+	public static void println(String message) {
+		if (thePrintWriter != null) {
+			thePrintWriter.println(message);
+			thePrintWriter.flush();
+		} else if (thePrintStream != null) {
+			thePrintStream.println(message);
+			thePrintStream.flush();
+		} // end if
+		// If neither the PrintWriter not the PrintStream are set, then silently
+		// do nothing
+		// the message is not recorded and no exception is generated.
+		return;
+	} // end method println( String )
+
+	/**
+	 * Registers a given JDBC driver with the DriverManager.
+	 * <p>
+	 * A newly loaded JDBC driver class should register itself with the
+	 * DriverManager by calling this method.
+	 * 
+	 * @param driver
+	 *            the Driver to register with the DriverManager
+	 * @throws SQLException
+	 *             if a database access error occurs.
+	 */
+	public static void registerDriver(Driver driver) throws SQLException {
+		if (driver == null)
+			throw new NullPointerException();
+		synchronized (theDriverSet) {
+			theDriverSet.add(driver);
+		} // end synchronized
+	} // end method registerDriver( Driver )
+
+	/**
+	 * Set the login timeout when connecting to a database, in seconds.
+	 * 
+	 * @param seconds
+	 *            seconds until timeout. 0 indicates wait forever.
+	 */
+	public static void setLoginTimeout(int seconds) {
+		loginTimeout = seconds;
+		return;
+	} // end method setLoginTimeout( int )
+
+	/**
+	 * @deprecated Sets the Print Stream to use for logging data from the
+	 *             DriverManager and the JDBC drivers.
+	 *             <p>
+	 *             Use setLogWriter instead.
+	 * @param out
+	 *            the PrintStream to use for logging.
+	 */
+	public static void setLogStream(PrintStream out) {
+		checkLogSecurity();
+		thePrintStream = out;
+	} // end method setLogStream( PrintStream )
+
+	/**
+	 * Sets the PrintWriter that will be used by all loaded drivers, and also
+	 * the DriverManager.
+	 * 
+	 * @param out
+	 *            the PrintWriter to be used
+	 */
+	public static void setLogWriter(PrintWriter out) {
+		checkLogSecurity();
+		thePrintWriter = out;
+	} // end method setLogWriter( PrintWriter )
+
+	/*
+	 * Method which checks to see if setting a logging stream is allowed by the
+	 * Security manager
+	 */
+	private static void checkLogSecurity() {
+		SecurityManager securityManager = System.getSecurityManager();
+		if (securityManager != null) {
+			// Throws a SecurityException if setting the log is not permitted
+			securityManager.checkPermission(logPermission);
+		} // end checkLogSecurity
+	} // end method checkLogSecurity
+
+} // end class DriverManager
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,74 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 holding information about Driver Properties for making a Connection.
+ * This class is returned from the <code>Driver.getDriverProperties</code>
+ * method and is useful in using Connections in an advanced way.
+ * 
+ */
+public class DriverPropertyInfo {
+
+	/**
+	 * If the value member can be chosen from a set of possible values, they are
+	 * contained here. Otherwise choices is null.
+	 */
+	public String[] choices;
+
+	/**
+	 * A description of the property. May be null.
+	 */
+	public String description;
+
+	/**
+	 * The name of the property.
+	 */
+	public String name;
+
+	/**
+	 * True when the value member must be provided during Driver.connect. False
+	 * otherwise.
+	 */
+	public boolean required;
+
+	/**
+	 * The current value associated with this property. This is based on the
+	 * data gathered by the getPropertyInfo method, the general Java environment
+	 * and the default values for the driver.
+	 */
+	public String value;
+
+	/**
+	 * Creates a DriverPropertyInfo instance with the supplied name and value.
+	 * Other members take their default values.
+	 * 
+	 * @param name
+	 *            The property name
+	 * @param value
+	 *            The property value
+	 */
+	public DriverPropertyInfo(String name, String value) {
+		this.name = name;
+		this.value = value;
+		this.choices = null;
+		this.description = null;
+		this.required = false;
+
+	} // end method DriverPropertyInfo
+
+} // end class DriverPropertyInfo
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,184 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+/**
+ * An interface used to get information about the types and properties of
+ * parameters in a PreparedStatement object.
+ * 
+ */
+public interface ParameterMetaData {
+
+	/**
+	 * Indicates that the parameter mode is IN.
+	 */
+	public static final int parameterModeIn = 1;
+
+	/**
+	 * Indicates that the parameter mode is INOUT.
+	 */
+	public static final int parameterModeInOut = 2;
+
+	/**
+	 * Indicates that the parameter mode is OUT.
+	 */
+	public static final int parameterModeOut = 4;
+
+	/**
+	 * Indicates that the parameter mode is not known.
+	 */
+	public static final int parameterModeUnknown = 0;
+
+	/**
+	 * Indicates that a parameter is not permitted to be NULL.
+	 */
+	public static final int parameterNoNulls = 0;
+
+	/**
+	 * Indicates that a parameter is permitted to be NULL.
+	 */
+	public static final int parameterNullable = 1;
+
+	/**
+	 * Indicates that whether a parameter is allowed to be null or not is not
+	 * known.
+	 */
+	public static final int parameterNullableUnknown = 2;
+
+	/**
+	 * Gets the fully-qualified name of the Java class which should be passed as
+	 * a parameter to the method <code>PreparedStatement.setObject</code>.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return a String with the fully qualified Java class name of the
+	 *         parameter with the specified index. This class name is used for
+	 *         custom mapping.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public String getParameterClassName(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets the number of parameters in the PreparedStatement for which this
+	 * ParameterMetaData contains information.
+	 * 
+	 * @return the number of parameters as an int
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public int getParameterCount() throws SQLException;
+
+	/**
+	 * Gets the mode of the specified parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return the parameters mode. Can be: ParameterMetaData.parameterModeIn,
+	 *         ParameterMetaData.parameterModeOut,
+	 *         ParameterMetaData.parameterModeInOut or
+	 *         ParameterMetaData.parameterModeUnknown.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public int getParameterMode(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets the SQL type of a specified parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return the type of the parameter - an SQL type as defined in
+	 *         java.sql.Types.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public int getParameterType(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets the database-specific type name of a specified parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return the type name for the parameter as used by the database. A
+	 *         fully-qualified name is returned if the parameter is a User
+	 *         Defined Type.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public String getParameterTypeName(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets the number of decimal digits for a specified parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return the number of decimal digits ("the precision") for the parameter.
+	 *         0 if the parameter is not a numeric type.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public int getPrecision(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets the number of digits after the decimal point for a specified
+	 * parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return the number of digits after the decimal point ("the scale") for
+	 *         the parameter. 0 if the parameter is not a numeric type.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public int getScale(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets whether null values are allowed for the specified parameter.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return indicator of nullability, can be:
+	 *         ParameterMetaData.parameterNoNulls,
+	 *         ParameterMetaData.parameterNullable, or
+	 *         ParameterMetaData.parameterNullableUnknown
+	 * @throws SQLException
+	 *             if a database error is encountered
+	 */
+	public int isNullable(int paramIndex) throws SQLException;
+
+	/**
+	 * Gets whether values for the specified parameter can be signed numbers.
+	 * 
+	 * @param paramIndex
+	 *            the index number of the parameter, where the first parameter
+	 *            has an index of 1
+	 * @return true if values can be signed numbers for this parameter, false
+	 *         otherwise.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public boolean isSigned(int paramIndex) throws SQLException;
+
+} // end interface ParameterMetaData
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/PreparedStatement.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/PreparedStatement.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/PreparedStatement.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/PreparedStatement.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,631 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+import java.util.Calendar;
+import java.net.URL;
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+
+/**
+ * An interface for a Precompiled SQL Statement.
+ * <p>
+ * An SQL Statement is put into a PreparedStatement and is precompiled so that
+ * it can be executed multiple times efficiently.
+ * <p>
+ * Setter methods are supplied in the PreparedStatement interface for the
+ * setting of IN parameters for the Statement. The setter method used for each
+ * IN parameter must match the type of the IN parameter being set.
+ * 
+ */
+public interface PreparedStatement extends Statement {
+
+	/**
+	 * Add a set of parameters to the PreparedStatement's command batch.
+	 * 
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void addBatch() throws SQLException;
+
+	/**
+	 * Clear the current parameter values.
+	 * <p>
+	 * Typically, parameter values are retained for multiple executions of the
+	 * Statement. Setting a parameter value replaces the previous value. This
+	 * method clears the values for all parameters, releasing all resources used
+	 * by those parameters.
+	 * 
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void clearParameters() throws SQLException;
+
+	/**
+	 * Executes the SQL statement in this PreparedStatement.
+	 * <p>
+	 * A PreparedStatement may return multiple results. The execute method
+	 * returns a flag indicating the kind of result produced by
+	 * PreparedStatement. The methods <code>
+	 * getResultSet</code> or
+	 * <code>getUpdateCount</code> are used to retrieve the first result,
+	 * while <code>getMoreResults</code> must be used to retrieve the second
+	 * and subsequent results.
+	 * 
+	 * @return true if the result of the execution is a ResultSet, false if
+	 *         there is no result or if the result is an update count.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public boolean execute() throws SQLException;
+
+	/**
+	 * Execute the SQL query in the PreparedStatement and return the ResultSet
+	 * generated by the query.
+	 * 
+	 * @return the ResultSet generated by the query - never null.
+	 * @throws SQLException
+	 *             if a database error happens or if the SQL statement does not
+	 *             produce a ResultSet.
+	 */
+	public ResultSet executeQuery() throws SQLException;
+
+	/**
+	 * Invoke the SQL command contained within the Prepared Statement. This
+	 * must be INSERT, UPDATE, DELETE, or a command that returns nothing.
+	 * 
+	 * @return the count of rows for INSERT, UPDATE or DELETE statements, 0 for
+	 *         statements that return nothing
+	 * @throws SQLException
+	 *             if a database error happens or if the SQL statement returns a
+	 *             ResultSet.
+	 */
+	public int executeUpdate() throws SQLException;
+
+	/**
+	 * Returns a ResultSetMetaData containing data from the ResultSet that is
+	 * produced when the PreparedStatement is invoked.
+	 * <p>
+	 * It is possible to know the Metadata for the ResultSet without executing
+	 * the PreparedStatement, because the PreparedStatement is precompiled. As a
+	 * result the Metadata can be queried ahead of time without actually
+	 * executing the statement.
+	 * 
+	 * @return a ResultSetMetaData object with the information about the columns
+	 *         of the ResultSet, if the driver can return a ResultSetMetaData.
+	 *         null otherwise.
+	 * @throws SQLException
+	 *             if there is a database error
+	 */
+	public ResultSetMetaData getMetaData() throws SQLException;
+
+	/**
+	 * Gets information about the parameters of the PreparedStatement.
+	 * 
+	 * @return a ParameterMetaData object which holds information about the
+	 *         number, type and properties of the parameters of this
+	 *         PreparedStatement.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public ParameterMetaData getParameterMetaData() throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the supplied Array object.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theArray
+	 *            a java.sql.Array holing the data to set.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setArray(int parameterIndex, Array theArray)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the content of a supplied
+	 * InputStream, which has a specified number of bytes.
+	 * <p>
+	 * This is a good method for setting an SQL LONVARCHAR parameter where the
+	 * length of the data is large. Data is read from the InputStream until
+	 * end-of-file is reached or the specified number of bytes is copied.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theInputStream
+	 *            the ASCII InputStream carrying the data to update the
+	 *            parameter
+	 * @param length
+	 *            the number of bytes in the InputStream to copy to the
+	 *            parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setAsciiStream(int parameterIndex, InputStream theInputStream,
+			int length) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied
+	 * java.math.BigDecimal value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theBigDecimal
+	 *            the java.math.BigInteger value to set
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setBigDecimal(int parameterIndex, BigDecimal theBigDecimal)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the content of a supplied
+	 * binary InputStream, which has a specified number of bytes.
+	 * <p>
+	 * Use this method when a large amount of data needs to be set into a
+	 * LONGVARBINARY parameter.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theInputStream
+	 *            the binary InputStream carrying the data to update the
+	 *            parameter
+	 * @param length
+	 *            the number of bytes in the InputStream to copy to the
+	 *            parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setBinaryStream(int parameterIndex, InputStream theInputStream,
+			int length) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the given Blob object.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theBlob
+	 *            a java.sql.Blob holding the data to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setBlob(int parameterIndex, Blob theBlob) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied boolean value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theBoolean
+	 *            the boolean value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setBoolean(int parameterIndex, boolean theBoolean)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied byte value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theByte
+	 *            the byte value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setByte(int parameterIndex, byte theByte) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied array of bytes. The
+	 * array is mapped to a VARBINARY or LONGVARBINARY in the database.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theBytes
+	 *            the array of bytes to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setBytes(int parameterIndex, byte[] theBytes)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the character content of a
+	 * Reader object, with the specified length of character data.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param reader
+	 *            the java.io.Reader encompassing the character data
+	 * @param length
+	 *            the amount of characters to be read
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setCharacterStream(int parameterIndex, Reader reader, int length)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to the given Clob object.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theClob
+	 *            a java.sql.Clob holding the data to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setClob(int parameterIndex, Clob theClob) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Date
+	 * value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theDate
+	 *            a java.sql.Date to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setDate(int parameterIndex, Date theDate) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Date
+	 * value, using a supplied Calendar to map the Date. The Calendar allows the
+	 * application to control the timezone used to compute the SQL DATE in the
+	 * database - without the supplied Calendar, the driver uses the default
+	 * timezone of the Java virtual machine.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theDate
+	 *            a java.sql.Date to update the parameter
+	 * @param cal
+	 *            a Calendar to use to construct the SQL DATE value
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setDate(int parameterIndex, Date theDate, Calendar cal)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied double value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theDouble
+	 *            the double value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setDouble(int parameterIndex, double theDouble)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to to a supplied float value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theFloat
+	 *            the float value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setFloat(int parameterIndex, float theFloat)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied int value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theInt
+	 *            the int value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setInt(int parameterIndex, int theInt) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied long value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theLong
+	 *            the long value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setLong(int parameterIndex, long theLong) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to SQL NULL. Don't use this
+	 * version of setNull for User Defined Types or for REF type parameters.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param sqlType
+	 *            the SQL Type of the parameter, as defined in java.sql.Types
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setNull(int parameterIndex, int sqlType) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to SQL NULL. This version of
+	 * setNull should be used for User Defined Types (UDTs) and also REF types.
+	 * UDTs can be STRUCT, DISTINCT, JAVA_OBJECT and named array types.
+	 * <p>
+	 * Applications must provide the SQL Type code and also a fully qualified
+	 * SQL Type name when supplying a NULL UDT or REF. For a UDT, the type name
+	 * is the type name of the parameter itself, but for a REF parameter the
+	 * type name is the type name of the referenced type.
+	 * 
+	 * @param paramIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param sqlType
+	 *            the SQL Type of the parameter, as defined in java.sql.Types
+	 * @param typeName
+	 *            the fully qualified name of a UDT or REF type - ignored if the
+	 *            parameter is not a UDT.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setNull(int paramIndex, int sqlType, String typeName)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter using a supplied object.
+	 * <p>
+	 * There is a standard mapping from Java types to SQL types, defined in the
+	 * JDBC specification. The passed object is then transformed into the
+	 * appropriate SQL type, and then transferred to the database. setObject can
+	 * be used to pass abstract data types unique to the database, by using a
+	 * JDBC driver specific Java type. If the object's class implements the
+	 * interface SQLData, the JDBC driver calls <code>SQLData.writeSQL</code>
+	 * to write it to the SQL data stream. If the object's class implements Ref,
+	 * Blob, Clob, Struct, or Array, the driver passes it to the database as a
+	 * value of the corresponding SQL type.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theObject
+	 *            the Object containing the value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setObject(int parameterIndex, Object theObject)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter using a supplied object.
+	 * <p>
+	 * The Object is converted to the given targetSqlType before it is sent to
+	 * the database. If the object has a custom mapping (its class implements
+	 * the interface SQLData), the JDBC driver will call the method
+	 * SQLData.writeSQL to write it to the SQL data stream. If the object's
+	 * class implements Ref, Blob, Clob, Struct, or Array, the driver will pass
+	 * it to the database in the form of the relevant SQL type.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter index, where the first parameter has index 1
+	 * @param theObject
+	 *            the Object containing the value to update the parameter
+	 * @param targetSqlType
+	 *            the SQL Type to send to the database, as defined in
+	 *            java.sql.Types
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setObject(int parameterIndex, Object theObject,
+			int targetSqlType) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter using a supplied object.
+	 * <p>
+	 * The Object is converted to the given targetSqlType before it is sent to
+	 * the database. If the object has a custom mapping (its class implements
+	 * the interface SQLData), the JDBC driver will call the method
+	 * SQLData.writeSQL to write it to the SQL data stream. If the object's
+	 * class implements Ref, Blob, Clob, Struct, or Array, the driver will pass
+	 * it to the database in the form of the relevant SQL type.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter index, where the first parameter has index 1
+	 * @param theObject
+	 *            the Object containing the value to update the parameter
+	 * @param targetSqlType
+	 *            the SQL Type to send to the database, as defined in
+	 *            java.sql.Types
+	 * @param scale
+	 *            the number of digits after the decimal point - only applies to
+	 *            the types java.sql.Types.DECIMAL and java.sql.Types.NUMERIC -
+	 *            ignored for all other types.
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setObject(int parameterIndex, Object theObject,
+			int targetSqlType, int scale) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied REF(<structured-type>)
+	 * value. This is stored as an SQL REF.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theRef
+	 *            a java.sql.Ref value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setRef(int parameterIndex, Ref theRef) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied short value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theShort
+	 *            a short value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setShort(int parameterIndex, short theShort)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied String.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theString
+	 *            a String value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setString(int parameterIndex, String theString)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Time
+	 * value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theTime
+	 *            a java.sql.Time value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setTime(int parameterIndex, Time theTime) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Time
+	 * value, using a supplied Calendar.
+	 * <p>
+	 * The driver uses the supplied Calendar to create the SQL TIME value, which
+	 * allows it to use a custom timezone - otherwise the driver uses the
+	 * default timezone of the Java virtual machine.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theTime
+	 *            a java.sql.Time value to update the parameter
+	 * @param cal
+	 *            a Calendar to use to construct the SQL TIME value
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setTime(int parameterIndex, Time theTime, Calendar cal)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Timestamp
+	 * value.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theTimestamp
+	 *            the java.sql.Timestamp value to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setTimestamp(int parameterIndex, Timestamp theTimestamp)
+			throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.sql.Timestamp
+	 * value, using the supplied Calendar.
+	 * <p>
+	 * The driver uses the supplied Calendar to create the SQL TIMESTAMP value,
+	 * which allows it to use a custom timezone - otherwise the driver uses the
+	 * default timezone of the Java virtual machine.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theTimestamp
+	 *            the java.sql.Timestamp value to update the parameter
+	 * @param cal
+	 *            a Calendar to use to construct the SQL TIMESTAMP value
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setTimestamp(int parameterIndex, Timestamp theTimestamp,
+			Calendar cal) throws SQLException;
+
+	/**
+	 * @deprecated Sets the value of a specified parameter to the characters
+	 *             from a supplied InputStream, with a specified number of
+	 *             bytes.
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theInputStream
+	 *            the InputStream with the character data to update the
+	 *            parameter
+	 * @param length
+	 *            the number of bytes to read from the InputStream
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setUnicodeStream(int parameterIndex,
+			InputStream theInputStream, int length) throws SQLException;
+
+	/**
+	 * Sets the value of a specified parameter to a supplied java.net.URL.
+	 * 
+	 * @param parameterIndex
+	 *            the parameter number index, where the first parameter has
+	 *            index 1
+	 * @param theURL
+	 *            the URL to update the parameter
+	 * @throws SQLException
+	 *             if a database error happens
+	 */
+	public void setURL(int parameterIndex, URL theURL) throws SQLException;
+
+} // end interface PreparedStatement
+

Added: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Ref.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Ref.java?rev=386087&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Ref.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Ref.java Wed Mar 15 06:55:38 2006
@@ -0,0 +1,80 @@
+/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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;
+
+import java.util.Map;
+
+/**
+ * A manifestation of the SQL REF type - a reference to an SQL type contained in
+ * the database.
+ * <p>
+ * The SQL REF's are held in a table along with SQL structured types. Every REF
+ * has an individual identifier for each single instance. The SQL REF is used
+ * instead of the structured type it references.
+ * <p>
+ * A Ref object is stored into the database using the PreparedStatement.setRef
+ * method.
+ * 
+ */
+public interface Ref {
+
+	/**
+	 * Gets the fully-qualified SQL name of the SQL structured type that this
+	 * Ref references.
+	 * 
+	 * @return the fully qualified name of the SQL structured type
+	 * @throws SQLException
+	 *             if there is a database error
+	 */
+	public String getBaseTypeName() throws SQLException;
+
+	/**
+	 * Gets the SQL structured type instance referenced by this Ref.
+	 * 
+	 * @return a Java object whose type is defined by the mapping for the SQL
+	 *         structured type.
+	 * @throws SQLException
+	 *             if there is a database error
+	 */
+	public Object getObject() throws SQLException;
+
+	/**
+	 * Returns the associated object and uses the relevant mapping to convert it
+	 * to a Java type.
+	 * 
+	 * @param map
+	 *            a java.util.Map which contains the mapping to use
+	 * @return a Java object whose type is defined by the mapping for the SQL
+	 *         structured type.
+	 * @throws SQLException
+	 *             if there is a database error
+	 */
+	public Object getObject(Map map) throws SQLException;
+
+	/**
+	 * Sets the value of the structured typethat this Ref references to a
+	 * supplied Object.
+	 * 
+	 * @param value
+	 *            the Object representing the new SQL structured type that this
+	 *            Ref will reference.
+	 * @throws SQLException
+	 *             if there is a database error
+	 */
+	public void setObject(Object value) throws SQLException;
+
+} // end interface Ref
+



Mime
View raw message