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 [5/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/Date.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Date.java Mon Jun 12 05:13:42 2006
@@ -11,185 +11,194 @@
* 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 {
-
- 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 */
-
-
+ */
+
+package java.sql;
+
+import java.text.SimpleDateFormat;
+import java.lang.IllegalArgumentException;
+import java.text.ParseException;
+
+/**
+ * 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 {
+
+ 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);
+ }
+
+ /**
+ * 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));
+ }
+
+ /**
+ * @deprecated This method is deprecated and must not be used. SQL Date
+ * values do not have an hours component.
+ * @return does not return
+ * @throws IllegalArgumentException
+ * if this method is called
+ */
+ public int getHours() {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * @deprecated This method is deprecated and must not be used. SQL Date
+ * values do not have a minutes component.
+ * @return does not return
+ * @throws IllegalArgumentException
+ * if this method is called
+ */
+ public int getMinutes() {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * @deprecated This method is deprecated and must not be used. SQL Date
+ * values do not have a seconds component.
+ * @return does not return
+ * @throws IllegalArgumentException
+ * if this method is called
+ */
+ public int getSeconds() {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * @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) {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * @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) {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * @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) {
+ throw new IllegalArgumentException();
+ }
+
+ /**
+ * 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));
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * 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();
+ }
+
+ return new Date(aDate.getTime());
+ }
+
+ /*
+ * 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;
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Driver.java Mon Jun 12 05:13:42 2006
@@ -11,82 +11,101 @@
* 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
-
-
+ */
+
+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();
+
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java Mon Jun 12 05:13:42 2006
@@ -18,6 +18,7 @@
import java.util.Properties;
import java.util.Enumeration;
import java.util.Iterator;
+import java.util.Set;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.HashSet;
@@ -30,367 +31,360 @@
* <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<Driver> 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
-
+ /*
+ * 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 Set<Driver> theDriverSet = new HashSet<Driver>(10);
+
+ // Permission for setting log
+ private static SQLPermission logPermission = new SQLPermission("setLog"); //$NON-NLS-1$
+
+ /*
+ * Load drivers on initialization
+ */
+ static {
+ loadInitialDrivers();
+ }
+
+ /*
+ * 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;
+ }
+
+ /*
+ * 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 (String element : theDriverNames) {
+ try {
+ // Load the driver class
+ Class
+ .forName(element, true, ClassLoader
+ .getSystemClassLoader());
+ } catch (Throwable t) {
+ // Ignored
+ }
+ }
+ }
+
+ /*
+ * A private constructor to prevent allocation
+ */
+ private DriverManager() {
+ super();
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * 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 {
+ return getConnection(url, new Properties());
+ }
+
+ /**
+ * 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;
+ }
+ }
+ }
+ // If we get here, none of the drivers are able to resolve the URL
+ throw new SQLException("No suitable driver");
+ }
+
+ /**
+ * 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");
+ }
+ Properties theProperties = new Properties();
+ theProperties.setProperty("user", user); //$NON-NLS-1$
+ theProperties.setProperty("password", password); //$NON-NLS-1$
+ return getConnection(url, theProperties);
+ }
+
+ /**
+ * 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<Driver> theIterator = theDriverSet.iterator();
+ while (theIterator.hasNext()) {
+ Driver theDriver = theIterator.next();
+ if (theDriver.acceptsURL(url)
+ && ClassUtils.isClassFromClassLoader(theDriver,
+ callerClassLoader)) {
+ return theDriver;
+ }
+ }
+ }
+ // If no drivers understand the URL, throw an SQLException
+ throw new SQLException("No suitable driver");
+ }
+
+ /**
+ * 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<Driver> getDrivers() {
+ 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<Driver> theVector = new Vector<Driver>();
+ Iterator<Driver> theIterator = theDriverSet.iterator();
+ while (theIterator.hasNext()) {
+ Driver theDriver = theIterator.next();
+ if (ClassUtils.isClassFromClassLoader(theDriver,
+ callerClassLoader)) {
+ theVector.add(theDriver);
+ }
+ }
+ return theVector.elements();
+ }
+ }
+
+ /**
+ * Returns the login timeout when connecting to a database, in seconds.
+ *
+ * @return the login timeout in seconds
+ */
+ public static int getLoginTimeout() {
+ return loginTimeout;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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();
+ }
+ /*
+ * If neither the PrintWriter not the PrintStream are set, then silently
+ * do nothing the message is not recorded and no exception is generated.
+ */
+ return;
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /*
+ * 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);
+ }
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverPropertyInfo.java Mon Jun 12 05:13:42 2006
@@ -19,56 +19,52 @@
* 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
-
+ /**
+ * 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;
+ }
+}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java?rev=413642&r1=413641&r2=413642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/ParameterMetaData.java Mon Jun 12 05:13:42 2006
@@ -18,167 +18,164 @@
/**
* 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
-
+ /**
+ * 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;
+}