feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,366 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The mapping in the Java programming language for the SQL type
* <code>ARRAY</code>.
* By default, an <code>Array</code> value is a transaction-duration
* reference to an SQL <code>ARRAY</code> value. By default, an <code>Array</code>
* object is implemented using an SQL LOCATOR(array) internally, which
* means that an <code>Array</code> object contains a logical pointer
* to the data in the SQL <code>ARRAY</code> value rather
* than containing the <code>ARRAY</code> value's data.
* <p>
* The <code>Array</code> interface provides methods for bringing an SQL
* <code>ARRAY</code> value's data to the client as either an array or a
* <code>ResultSet</code> object.
* If the elements of the SQL <code>ARRAY</code>
* are a UDT, they may be custom mapped. To create a custom mapping,
* a programmer must do two things:
* <ul>
* <li>create a class that implements the {@link SQLData}
* interface for the UDT to be custom mapped.
* <li>make an entry in a type map that contains
* <ul>
* <li>the fully-qualified SQL type name of the UDT
* <li>the <code>Class</code> object for the class implementing
* <code>SQLData</code>
* </ul>
* </ul>
* <p>
* When a type map with an entry for
* the base type is supplied to the methods <code>getArray</code>
* and <code>getResultSet</code>, the mapping
* it contains will be used to map the elements of the <code>ARRAY</code> value.
* If no type map is supplied, which would typically be the case,
* the connection's type map is used by default.
* If the connection's type map or a type map supplied to a method has no entry
* for the base type, the elements are mapped according to the standard mapping.
* <p>
* All methods on the <code>Array</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.2
*/
public interface Array {
/**
* Retrieves the SQL type name of the elements in
* the array designated by this <code>Array</code> object.
* If the elements are a built-in type, it returns
* the database-specific type name of the elements.
* If the elements are a user-defined type (UDT),
* this method returns the fully-qualified SQL type name.
*
* @return a <code>String</code> that is the database-specific
* name for a built-in base type; or the fully-qualified SQL type
* name for a base type that is a UDT
* @exception SQLException if an error occurs while attempting
* to access the type name
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String getBaseTypeName() throws SQLException;
/**
* Retrieves the JDBC type of the elements in the array designated
* by this <code>Array</code> object.
*
* @return a constant from the class {@link java.sql.Types} that is
* the type code for the elements in the array designated by this
* <code>Array</code> object
* @exception SQLException if an error occurs while attempting
* to access the base type
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
int getBaseType() throws SQLException;
/**
* Retrieves the contents of the SQL <code>ARRAY</code> value designated
* by this
* <code>Array</code> object in the form of an array in the Java
* programming language. This version of the method <code>getArray</code>
* uses the type map associated with the connection for customizations of
* the type mappings.
* <p>
* <strong>Note:</strong> When <code>getArray</code> is used to materialize
* a base type that maps to a primitive data type, then it is
* implementation-defined whether the array returned is an array of
* that primitive data type or an array of <code>Object</code>.
*
* @return an array in the Java programming language that contains
* the ordered elements of the SQL <code>ARRAY</code> value
* designated by this <code>Array</code> object
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object getArray() throws SQLException;
/**
* Retrieves the contents of the SQL <code>ARRAY</code> value designated by this
* <code>Array</code> object.
* This method uses
* the specified <code>map</code> for type map customizations
* unless the base type of the array does not match a user-defined
* type in <code>map</code>, in which case it
* uses the standard mapping. This version of the method
* <code>getArray</code> uses either the given type map or the standard mapping;
* it never uses the type map associated with the connection.
* <p>
* <strong>Note:</strong> When <code>getArray</code> is used to materialize
* a base type that maps to a primitive data type, then it is
* implementation-defined whether the array returned is an array of
* that primitive data type or an array of <code>Object</code>.
*
* @param map a <code>java.util.Map</code> object that contains mappings
* of SQL type names to classes in the Java programming language
* @return an array in the Java programming language that contains the ordered
* elements of the SQL array designated by this object
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object getArray(java.util.Map<String,Class<?>> map) throws SQLException;
/**
* Retrieves a slice of the SQL <code>ARRAY</code>
* value designated by this <code>Array</code> object, beginning with the
* specified <code>index</code> and containing up to <code>count</code>
* successive elements of the SQL array. This method uses the type map
* associated with the connection for customizations of the type mappings.
* <p>
* <strong>Note:</strong> When <code>getArray</code> is used to materialize
* a base type that maps to a primitive data type, then it is
* implementation-defined whether the array returned is an array of
* that primitive data type or an array of <code>Object</code>.
*
* @param index the array index of the first element to retrieve;
* the first element is at index 1
* @param count the number of successive SQL array elements to retrieve
* @return an array containing up to <code>count</code> consecutive elements
* of the SQL array, beginning with element <code>index</code>
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object getArray(long index, int count) throws SQLException;
/**
* Retreives a slice of the SQL <code>ARRAY</code> value
* designated by this <code>Array</code> object, beginning with the specified
* <code>index</code> and containing up to <code>count</code>
* successive elements of the SQL array.
* <P>
* This method uses
* the specified <code>map</code> for type map customizations
* unless the base type of the array does not match a user-defined
* type in <code>map</code>, in which case it
* uses the standard mapping. This version of the method
* <code>getArray</code> uses either the given type map or the standard mapping;
* it never uses the type map associated with the connection.
* <p>
* <strong>Note:</strong> When <code>getArray</code> is used to materialize
* a base type that maps to a primitive data type, then it is
* implementation-defined whether the array returned is an array of
* that primitive data type or an array of <code>Object</code>.
*
* @param index the array index of the first element to retrieve;
* the first element is at index 1
* @param count the number of successive SQL array elements to
* retrieve
* @param map a <code>java.util.Map</code> object
* that contains SQL type names and the classes in
* the Java programming language to which they are mapped
* @return an array containing up to <code>count</code>
* consecutive elements of the SQL <code>ARRAY</code> value designated by this
* <code>Array</code> object, beginning with element
* <code>index</code>
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object getArray(long index, int count, java.util.Map<String,Class<?>> map)
throws SQLException;
/**
* Retrieves a result set that contains the elements of the SQL
* <code>ARRAY</code> value
* designated by this <code>Array</code> object. If appropriate,
* the elements of the array are mapped using the connection's type
* map; otherwise, the standard mapping is used.
* <p>
* The result set contains one row for each array element, with
* two columns in each row. The second column stores the element
* value; the first column stores the index into the array for
* that element (with the first array element being at index 1).
* The rows are in ascending order corresponding to
* the order of the indices.
*
* @return a {@link ResultSet} object containing one row for each
* of the elements in the array designated by this <code>Array</code>
* object, with the rows in ascending order based on the indices.
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
ResultSet getResultSet () throws SQLException;
/**
* Retrieves a result set that contains the elements of the SQL
* <code>ARRAY</code> value designated by this <code>Array</code> object.
* This method uses
* the specified <code>map</code> for type map customizations
* unless the base type of the array does not match a user-defined
* type in <code>map</code>, in which case it
* uses the standard mapping. This version of the method
* <code>getResultSet</code> uses either the given type map or the standard mapping;
* it never uses the type map associated with the connection.
* <p>
* The result set contains one row for each array element, with
* two columns in each row. The second column stores the element
* value; the first column stores the index into the array for
* that element (with the first array element being at index 1).
* The rows are in ascending order corresponding to
* the order of the indices.
*
* @param map contains the mapping of SQL user-defined types to
* classes in the Java programming language
* @return a <code>ResultSet</code> object containing one row for each
* of the elements in the array designated by this <code>Array</code>
* object, with the rows in ascending order based on the indices.
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
ResultSet getResultSet (java.util.Map<String,Class<?>> map) throws SQLException;
/**
* Retrieves a result set holding the elements of the subarray that
* starts at index <code>index</code> and contains up to
* <code>count</code> successive elements. This method uses
* the connection's type map to map the elements of the array if
* the map contains an entry for the base type. Otherwise, the
* standard mapping is used.
* <P>
* The result set has one row for each element of the SQL array
* designated by this object, with the first row containing the
* element at index <code>index</code>. The result set has
* up to <code>count</code> rows in ascending order based on the
* indices. Each row has two columns: The second column stores
* the element value; the first column stores the index into the
* array for that element.
*
* @param index the array index of the first element to retrieve;
* the first element is at index 1
* @param count the number of successive SQL array elements to retrieve
* @return a <code>ResultSet</code> object containing up to
* <code>count</code> consecutive elements of the SQL array
* designated by this <code>Array</code> object, starting at
* index <code>index</code>.
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
ResultSet getResultSet(long index, int count) throws SQLException;
/**
* Retrieves a result set holding the elements of the subarray that
* starts at index <code>index</code> and contains up to
* <code>count</code> successive elements.
* This method uses
* the specified <code>map</code> for type map customizations
* unless the base type of the array does not match a user-defined
* type in <code>map</code>, in which case it
* uses the standard mapping. This version of the method
* <code>getResultSet</code> uses either the given type map or the standard mapping;
* it never uses the type map associated with the connection.
* <P>
* The result set has one row for each element of the SQL array
* designated by this object, with the first row containing the
* element at index <code>index</code>. The result set has
* up to <code>count</code> rows in ascending order based on the
* indices. Each row has two columns: The second column stores
* the element value; the first column stores the index into the
* array for that element.
*
* @param index the array index of the first element to retrieve;
* the first element is at index 1
* @param count the number of successive SQL array elements to retrieve
* @param map the <code>Map</code> object that contains the mapping
* of SQL type names to classes in the Java(tm) programming language
* @return a <code>ResultSet</code> object containing up to
* <code>count</code> consecutive elements of the SQL array
* designated by this <code>Array</code> object, starting at
* index <code>index</code>.
* @exception SQLException if an error occurs while attempting to
* access the array
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
ResultSet getResultSet (long index, int count,
java.util.Map<String,Class<?>> map)
throws SQLException;
/**
* This method frees the <code>Array</code> object and releases the resources that
* it holds. The object is invalid once the <code>free</code>
* method is called.
*<p>
* After <code>free</code> has been called, any attempt to invoke a
* method other than <code>free</code> will result in a <code>SQLException</code>
* being thrown. If <code>free</code> is called multiple times, the subsequent
* calls to <code>free</code> are treated as a no-op.
*<p>
*
* @throws SQLException if an error occurs releasing
* the Array's resources
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void free() throws SQLException;
}

View File

@@ -0,0 +1,564 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
/**
* The subclass of {@link SQLException} thrown when an error
* occurs during a batch update operation. In addition to the
* information provided by {@link SQLException}, a
* <code>BatchUpdateException</code> provides the update
* counts for all commands that were executed successfully during the
* batch update, that is, all commands that were executed before the error
* occurred. The order of elements in an array of update counts
* corresponds to the order in which commands were added to the batch.
* <P>
* After a command in a batch update fails to execute properly
* and a <code>BatchUpdateException</code> is thrown, the driver
* may or may not continue to process the remaining commands in
* the batch. If the driver continues processing after a failure,
* the array returned by the method
* <code>BatchUpdateException.getUpdateCounts</code> will have
* an element for every command in the batch rather than only
* elements for the commands that executed successfully before
* the error. In the case where the driver continues processing
* commands, the array element for any command
* that failed is <code>Statement.EXECUTE_FAILED</code>.
* <P>
* A JDBC driver implementation should use
* the constructor {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) } instead of
* constructors that take {@code int[]} for the update counts to avoid the
* possibility of overflow.
* <p>
* If {@code Statement.executeLargeBatch} method is invoked it is recommended that
* {@code getLargeUpdateCounts} be called instead of {@code getUpdateCounts}
* in order to avoid a possible overflow of the integer update count.
* @since 1.2
*/
public class BatchUpdateException extends SQLException {
/**
* Constructs a <code>BatchUpdateException</code> object initialized with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code> and
* <code>updateCounts</code>.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param reason a description of the error
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode an exception code used by a particular
* database vendor
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @since 1.2
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException( String reason, String SQLState, int vendorCode,
int[] updateCounts ) {
super(reason, SQLState, vendorCode);
this.updateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with a given
* <code>reason</code>, <code>SQLState</code> and
* <code>updateCounts</code>.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @since 1.2
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(String reason, String SQLState,
int[] updateCounts) {
this(reason, SQLState, 0, updateCounts);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with a given
* <code>reason</code> and <code>updateCounts</code>.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The
* <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param reason a description of the exception
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @since 1.2
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(String reason, int[] updateCounts) {
this(reason, null, 0, updateCounts);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with a given
* <code>updateCounts</code>.
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The <code>reason</code>
* and <code>SQLState</code> are initialized to null and the vendor code
* is initialized to 0.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @since 1.2
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(int[] updateCounts) {
this(null, null, 0, updateCounts);
}
/**
* Constructs a <code>BatchUpdateException</code> object.
* The <code>reason</code>, <code>SQLState</code> and <code>updateCounts</code>
* are initialized to <code>null</code> and the vendor code is initialized to 0.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @since 1.2
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException() {
this(null, null, 0, null);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with
* a given <code>cause</code>.
* The <code>SQLState</code> and <code>updateCounts</code>
* are initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
* @since 1.6
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(Throwable cause) {
this((cause == null ? null : cause.toString()), null, 0, (int[])null, cause);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with a
* given <code>cause</code> and <code>updateCounts</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(int []updateCounts , Throwable cause) {
this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with
* a given <code>reason</code>, <code>cause</code>
* and <code>updateCounts</code>. The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param reason a description of the exception
* @param updateCounts an array of <code>int</code>, with each element
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(String reason, int []updateCounts, Throwable cause) {
this(reason, null, 0, updateCounts, cause);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with
* a given <code>reason</code>, <code>SQLState</code>,<code>cause</code>, and
* <code>updateCounts</code>. The vendor code is initialized to 0.
*
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param updateCounts an array of <code>int</code>, with each element
* indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(String reason, String SQLState,
int []updateCounts, Throwable cause) {
this(reason, SQLState, 0, updateCounts, cause);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with
* a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* <code>cause</code> and <code>updateCounts</code>.
*
* @param reason a description of the error
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode an exception code used by a particular
* database vendor
* @param updateCounts an array of <code>int</code>, with each element
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* <p>
* <strong>Note:</strong> There is no validation of {@code updateCounts} for
* overflow and because of this it is recommended that you use the constructor
* {@code BatchUpdateException(String reason, String SQLState,
* int vendorCode, long []updateCounts,Throwable cause) }.
* </p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
* @see #BatchUpdateException(java.lang.String, java.lang.String, int, long[],
* java.lang.Throwable)
*/
public BatchUpdateException(String reason, String SQLState, int vendorCode,
int []updateCounts,Throwable cause) {
super(reason, SQLState, vendorCode, cause);
this.updateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
this.longUpdateCounts = (updateCounts == null) ? null : copyUpdateCount(updateCounts);
}
/**
* Retrieves the update count for each update statement in the batch
* update that executed successfully before this exception occurred.
* A driver that implements batch updates may or may not continue to
* process the remaining commands in a batch when one of the commands
* fails to execute properly. If the driver continues processing commands,
* the array returned by this method will have as many elements as
* there are commands in the batch; otherwise, it will contain an
* update count for each command that executed successfully before
* the <code>BatchUpdateException</code> was thrown.
*<P>
* The possible return values for this method were modified for
* the Java 2 SDK, Standard Edition, version 1.3. This was done to
* accommodate the new option of continuing to process commands
* in a batch update after a <code>BatchUpdateException</code> object
* has been thrown.
*
* @return an array of <code>int</code> containing the update counts
* for the updates that were executed successfully before this error
* occurred. Or, if the driver continues to process commands after an
* error, one of the following for every command in the batch:
* <OL>
* <LI>an update count
* <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
* executed successfully but the number of rows affected is unknown
* <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
* failed to execute successfully
* </OL>
* @since 1.3
* @see #getLargeUpdateCounts()
*/
public int[] getUpdateCounts() {
return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
}
/**
* Constructs a <code>BatchUpdateException</code> object initialized with
* a given <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* <code>cause</code> and <code>updateCounts</code>.
* <p>
* This constructor should be used when the returned update count may exceed
* {@link Integer#MAX_VALUE}.
* <p>
* @param reason a description of the error
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode an exception code used by a particular
* database vendor
* @param updateCounts an array of <code>long</code>, with each element
*indicating the update count, <code>Statement.SUCCESS_NO_INFO</code> or
* <code>Statement.EXECUTE_FAILED</code> for each SQL command in
* the batch for JDBC drivers that continue processing
* after a command failure; an update count or
* <code>Statement.SUCCESS_NO_INFO</code> for each SQL command in the batch
* prior to the failure for JDBC drivers that stop processing after a command
* failure
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
* @since 1.8
*/
public BatchUpdateException(String reason, String SQLState, int vendorCode,
long []updateCounts,Throwable cause) {
super(reason, SQLState, vendorCode, cause);
this.longUpdateCounts = (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length);
this.updateCounts = (longUpdateCounts == null) ? null : copyUpdateCount(longUpdateCounts);
}
/**
* Retrieves the update count for each update statement in the batch
* update that executed successfully before this exception occurred.
* A driver that implements batch updates may or may not continue to
* process the remaining commands in a batch when one of the commands
* fails to execute properly. If the driver continues processing commands,
* the array returned by this method will have as many elements as
* there are commands in the batch; otherwise, it will contain an
* update count for each command that executed successfully before
* the <code>BatchUpdateException</code> was thrown.
* <p>
* This method should be used when {@code Statement.executeLargeBatch} is
* invoked and the returned update count may exceed {@link Integer#MAX_VALUE}.
* <p>
* @return an array of <code>long</code> containing the update counts
* for the updates that were executed successfully before this error
* occurred. Or, if the driver continues to process commands after an
* error, one of the following for every command in the batch:
* <OL>
* <LI>an update count
* <LI><code>Statement.SUCCESS_NO_INFO</code> to indicate that the command
* executed successfully but the number of rows affected is unknown
* <LI><code>Statement.EXECUTE_FAILED</code> to indicate that the command
* failed to execute successfully
* </OL>
* @since 1.8
*/
public long[] getLargeUpdateCounts() {
return (longUpdateCounts == null) ? null :
Arrays.copyOf(longUpdateCounts, longUpdateCounts.length);
}
/**
* The array that describes the outcome of a batch execution.
* @serial
* @since 1.2
*/
private int[] updateCounts;
/*
* Starting with Java SE 8, JDBC has added support for returning an update
* count > Integer.MAX_VALUE. Because of this the following changes were made
* to BatchUpdateException:
* <ul>
* <li>Add field longUpdateCounts</li>
* <li>Add Constructorr which takes long[] for update counts</li>
* <li>Add getLargeUpdateCounts method</li>
* </ul>
* When any of the constructors are called, the int[] and long[] updateCount
* fields are populated by copying the one array to each other.
*
* As the JDBC driver passes in the updateCounts, there has always been the
* possiblity for overflow and BatchUpdateException does not need to account
* for that, it simply copies the arrays.
*
* JDBC drivers should always use the constructor that specifies long[] and
* JDBC application developers should call getLargeUpdateCounts.
*/
/**
* The array that describes the outcome of a batch execution.
* @serial
* @since 1.8
*/
private long[] longUpdateCounts;
private static final long serialVersionUID = 5977529877145521757L;
/*
* Utility method to copy int[] updateCount to long[] updateCount
*/
private static long[] copyUpdateCount(int[] uc) {
long[] copy = new long[uc.length];
for(int i= 0; i< uc.length; i++) {
copy[i] = uc[i];
}
return copy;
}
/*
* Utility method to copy long[] updateCount to int[] updateCount.
* No checks for overflow will be done as it is expected a user will call
* getLargeUpdateCounts.
*/
private static int[] copyUpdateCount(long[] uc) {
int[] copy = new int[uc.length];
for(int i= 0; i< uc.length; i++) {
copy[i] = (int) uc[i];
}
return copy;
}
/**
* readObject is called to restore the state of the
* {@code BatchUpdateException} from a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
int[] tmp = (int[])fields.get("updateCounts", null);
long[] tmp2 = (long[])fields.get("longUpdateCounts", null);
if(tmp != null && tmp2 != null && tmp.length != tmp2.length)
throw new InvalidObjectException("update counts are not the expected size");
if (tmp != null)
updateCounts = tmp.clone();
if (tmp2 != null)
longUpdateCounts = tmp2.clone();
if(updateCounts == null && longUpdateCounts != null)
updateCounts = copyUpdateCount(longUpdateCounts);
if(longUpdateCounts == null && updateCounts != null)
longUpdateCounts = copyUpdateCount(updateCounts);
}
/**
* writeObject is called to save the state of the {@code BatchUpdateException}
* to a stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("updateCounts", updateCounts);
fields.put("longUpdateCounts", longUpdateCounts);
s.writeFields();
}
}

View File

@@ -0,0 +1,304 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.io.InputStream;
/**
* The representation (mapping) in
* the Java&trade; programming
* language of an SQL
* <code>BLOB</code> value. An SQL <code>BLOB</code> is a built-in type
* that stores a Binary Large Object as a column value in a row of
* a database table. By default drivers implement <code>Blob</code> using
* an SQL <code>locator(BLOB)</code>, which means that a
* <code>Blob</code> object contains a logical pointer to the
* SQL <code>BLOB</code> data rather than the data itself.
* A <code>Blob</code> object is valid for the duration of the
* transaction in which is was created.
*
* <P>Methods in the interfaces {@link ResultSet},
* {@link CallableStatement}, and {@link PreparedStatement}, such as
* <code>getBlob</code> and <code>setBlob</code> allow a programmer to
* access an SQL <code>BLOB</code> value.
* The <code>Blob</code> interface provides methods for getting the
* length of an SQL <code>BLOB</code> (Binary Large Object) value,
* for materializing a <code>BLOB</code> value on the client, and for
* determining the position of a pattern of bytes within a
* <code>BLOB</code> value. In addition, this interface has methods for updating
* a <code>BLOB</code> value.
* <p>
* All methods on the <code>Blob</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.2
*/
public interface Blob {
/**
* Returns the number of bytes in the <code>BLOB</code> value
* designated by this <code>Blob</code> object.
* @return length of the <code>BLOB</code> in bytes
* @exception SQLException if there is an error accessing the
* length of the <code>BLOB</code>
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long length() throws SQLException;
/**
* Retrieves all or part of the <code>BLOB</code>
* value that this <code>Blob</code> object represents, as an array of
* bytes. This <code>byte</code> array contains up to <code>length</code>
* consecutive bytes starting at position <code>pos</code>.
*
* @param pos the ordinal position of the first byte in the
* <code>BLOB</code> value to be extracted; the first byte is at
* position 1
* @param length the number of consecutive bytes to be copied; the value
* for length must be 0 or greater
* @return a byte array containing up to <code>length</code>
* consecutive bytes from the <code>BLOB</code> value designated
* by this <code>Blob</code> object, starting with the
* byte at position <code>pos</code>
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value; if pos is less than 1 or length is
* less than 0
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #setBytes
* @since 1.2
*/
byte[] getBytes(long pos, int length) throws SQLException;
/**
* Retrieves the <code>BLOB</code> value designated by this
* <code>Blob</code> instance as a stream.
*
* @return a stream containing the <code>BLOB</code> data
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #setBinaryStream
* @since 1.2
*/
java.io.InputStream getBinaryStream () throws SQLException;
/**
* Retrieves the byte position at which the specified byte array
* <code>pattern</code> begins within the <code>BLOB</code>
* value that this <code>Blob</code> object represents. The
* search for <code>pattern</code> begins at position
* <code>start</code>.
*
* @param pattern the byte array for which to search
* @param start the position at which to begin searching; the
* first position is 1
* @return the position at which the pattern appears, else -1
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> or if start is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long position(byte pattern[], long start) throws SQLException;
/**
* Retrieves the byte position in the <code>BLOB</code> value
* designated by this <code>Blob</code> object at which
* <code>pattern</code> begins. The search begins at position
* <code>start</code>.
*
* @param pattern the <code>Blob</code> object designating
* the <code>BLOB</code> value for which to search
* @param start the position in the <code>BLOB</code> value
* at which to begin searching; the first position is 1
* @return the position at which the pattern begins, else -1
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value or if start is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long position(Blob pattern, long start) throws SQLException;
// -------------------------- JDBC 3.0 -----------------------------------
/**
* Writes the given array of bytes to the <code>BLOB</code> value that
* this <code>Blob</code> object represents, starting at position
* <code>pos</code>, and returns the number of bytes written.
* The array of bytes will overwrite the existing bytes
* in the <code>Blob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Blob</code> value is reached
* while writing the array of bytes, then the length of the <code>Blob</code>
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>BLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position in the <code>BLOB</code> object at which
* to start writing; the first position is 1
* @param bytes the array of bytes to be written to the <code>BLOB</code>
* value that this <code>Blob</code> object represents
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getBytes
* @since 1.4
*/
int setBytes(long pos, byte[] bytes) throws SQLException;
/**
* Writes all or part of the given <code>byte</code> array to the
* <code>BLOB</code> value that this <code>Blob</code> object represents
* and returns the number of bytes written.
* Writing starts at position <code>pos</code> in the <code>BLOB</code>
* value; <code>len</code> bytes from the given byte array are written.
* The array of bytes will overwrite the existing bytes
* in the <code>Blob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Blob</code> value is reached
* while writing the array of bytes, then the length of the <code>Blob</code>
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>BLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position in the <code>BLOB</code> object at which
* to start writing; the first position is 1
* @param bytes the array of bytes to be written to this <code>BLOB</code>
* object
* @param offset the offset into the array <code>bytes</code> at which
* to start reading the bytes to be set
* @param len the number of bytes to be written to the <code>BLOB</code>
* value from the array of bytes <code>bytes</code>
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getBytes
* @since 1.4
*/
int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException;
/**
* Retrieves a stream that can be used to write to the <code>BLOB</code>
* value that this <code>Blob</code> object represents. The stream begins
* at position <code>pos</code>.
* The bytes written to the stream will overwrite the existing bytes
* in the <code>Blob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Blob</code> value is reached
* while writing to the stream, then the length of the <code>Blob</code>
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>BLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position in the <code>BLOB</code> value at which
* to start writing; the first position is 1
* @return a <code>java.io.OutputStream</code> object to which data can
* be written
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getBinaryStream
* @since 1.4
*/
java.io.OutputStream setBinaryStream(long pos) throws SQLException;
/**
* Truncates the <code>BLOB</code> value that this <code>Blob</code>
* object represents to be <code>len</code> bytes in length.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>BLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param len the length, in bytes, to which the <code>BLOB</code> value
* that this <code>Blob</code> object represents should be truncated
* @exception SQLException if there is an error accessing the
* <code>BLOB</code> value or if len is less than 0
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void truncate(long len) throws SQLException;
/**
* This method frees the <code>Blob</code> object and releases the resources that
* it holds. The object is invalid once the <code>free</code>
* method is called.
*<p>
* After <code>free</code> has been called, any attempt to invoke a
* method other than <code>free</code> will result in a <code>SQLException</code>
* being thrown. If <code>free</code> is called multiple times, the subsequent
* calls to <code>free</code> are treated as a no-op.
*<p>
*
* @throws SQLException if an error occurs releasing
* the Blob's resources
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void free() throws SQLException;
/**
* Returns an <code>InputStream</code> object that contains a partial <code>Blob</code> value,
* starting with the byte specified by pos, which is length bytes in length.
*
* @param pos the offset to the first byte of the partial value to be retrieved.
* The first byte in the <code>Blob</code> is at position 1
* @param length the length in bytes of the partial value to be retrieved
* @return <code>InputStream</code> through which the partial <code>Blob</code> value can be read.
* @throws SQLException if pos is less than 1 or if pos is greater than the number of bytes
* in the <code>Blob</code> or if pos + length is greater than the number of bytes
* in the <code>Blob</code>
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
InputStream getBinaryStream(long pos, long length) throws SQLException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.*;
/**
* Enumeration for status of the reason that a property could not be set
* via a call to <code>Connection.setClientInfo</code>
* @since 1.6
*/
public enum ClientInfoStatus {
/**
* The client info property could not be set for some unknown reason
* @since 1.6
*/
REASON_UNKNOWN,
/**
* The client info property name specified was not a recognized property
* name.
* @since 1.6
*/
REASON_UNKNOWN_PROPERTY,
/**
* The value specified for the client info property was not valid.
* @since 1.6
*/
REASON_VALUE_INVALID,
/**
* The value specified for the client info property was too large.
* @since 1.6
*/
REASON_VALUE_TRUNCATED
}

View File

@@ -0,0 +1,348 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.io.Reader;
/**
* The mapping in the Java&trade; programming language
* for the SQL <code>CLOB</code> type.
* An SQL <code>CLOB</code> is a built-in type
* that stores a Character Large Object as a column value in a row of
* a database table.
* By default drivers implement a <code>Clob</code> object using an SQL
* <code>locator(CLOB)</code>, which means that a <code>Clob</code> object
* contains a logical pointer to the SQL <code>CLOB</code> data rather than
* the data itself. A <code>Clob</code> object is valid for the duration
* of the transaction in which it was created.
* <P>The <code>Clob</code> interface provides methods for getting the
* length of an SQL <code>CLOB</code> (Character Large Object) value,
* for materializing a <code>CLOB</code> value on the client, and for
* searching for a substring or <code>CLOB</code> object within a
* <code>CLOB</code> value.
* Methods in the interfaces {@link ResultSet},
* {@link CallableStatement}, and {@link PreparedStatement}, such as
* <code>getClob</code> and <code>setClob</code> allow a programmer to
* access an SQL <code>CLOB</code> value. In addition, this interface
* has methods for updating a <code>CLOB</code> value.
* <p>
* All methods on the <code>Clob</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.2
*/
public interface Clob {
/**
* Retrieves the number of characters
* in the <code>CLOB</code> value
* designated by this <code>Clob</code> object.
*
* @return length of the <code>CLOB</code> in characters
* @exception SQLException if there is an error accessing the
* length of the <code>CLOB</code> value
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long length() throws SQLException;
/**
* Retrieves a copy of the specified substring
* in the <code>CLOB</code> value
* designated by this <code>Clob</code> object.
* The substring begins at position
* <code>pos</code> and has up to <code>length</code> consecutive
* characters.
*
* @param pos the first character of the substring to be extracted.
* The first character is at position 1.
* @param length the number of consecutive characters to be copied;
* the value for length must be 0 or greater
* @return a <code>String</code> that is the specified substring in
* the <code>CLOB</code> value designated by this <code>Clob</code> object
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value; if pos is less than 1 or length is
* less than 0
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String getSubString(long pos, int length) throws SQLException;
/**
* Retrieves the <code>CLOB</code> value designated by this <code>Clob</code>
* object as a <code>java.io.Reader</code> object (or as a stream of
* characters).
*
* @return a <code>java.io.Reader</code> object containing the
* <code>CLOB</code> data
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #setCharacterStream
* @since 1.2
*/
java.io.Reader getCharacterStream() throws SQLException;
/**
* Retrieves the <code>CLOB</code> value designated by this <code>Clob</code>
* object as an ascii stream.
*
* @return a <code>java.io.InputStream</code> object containing the
* <code>CLOB</code> data
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #setAsciiStream
* @since 1.2
*/
java.io.InputStream getAsciiStream() throws SQLException;
/**
* Retrieves the character position at which the specified substring
* <code>searchstr</code> appears in the SQL <code>CLOB</code> value
* represented by this <code>Clob</code> object. The search
* begins at position <code>start</code>.
*
* @param searchstr the substring for which to search
* @param start the position at which to begin searching; the first position
* is 1
* @return the position at which the substring appears or -1 if it is not
* present; the first position is 1
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long position(String searchstr, long start) throws SQLException;
/**
* Retrieves the character position at which the specified
* <code>Clob</code> object <code>searchstr</code> appears in this
* <code>Clob</code> object. The search begins at position
* <code>start</code>.
*
* @param searchstr the <code>Clob</code> object for which to search
* @param start the position at which to begin searching; the first
* position is 1
* @return the position at which the <code>Clob</code> object appears
* or -1 if it is not present; the first position is 1
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if start is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long position(Clob searchstr, long start) throws SQLException;
//---------------------------- jdbc 3.0 -----------------------------------
/**
* Writes the given Java <code>String</code> to the <code>CLOB</code>
* value that this <code>Clob</code> object designates at the position
* <code>pos</code>. The string will overwrite the existing characters
* in the <code>Clob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Clob</code> value is reached
* while writing the given string, then the length of the <code>Clob</code>
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>CLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to the <code>CLOB</code>
* value that this <code>Clob</code> object represents;
* The first position is 1
* @param str the string to be written to the <code>CLOB</code>
* value that this <code>Clob</code> designates
* @return the number of characters written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if pos is less than 1
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
int setString(long pos, String str) throws SQLException;
/**
* Writes <code>len</code> characters of <code>str</code>, starting
* at character <code>offset</code>, to the <code>CLOB</code> value
* that this <code>Clob</code> represents. The string will overwrite the existing characters
* in the <code>Clob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Clob</code> value is reached
* while writing the given string, then the length of the <code>Clob</code>
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>CLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to this
* <code>CLOB</code> object; The first position is 1
* @param str the string to be written to the <code>CLOB</code>
* value that this <code>Clob</code> object represents
* @param offset the offset into <code>str</code> to start reading
* the characters to be written
* @param len the number of characters to be written
* @return the number of characters written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if pos is less than 1
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
int setString(long pos, String str, int offset, int len) throws SQLException;
/**
* Retrieves a stream to be used to write Ascii characters to the
* <code>CLOB</code> value that this <code>Clob</code> object represents,
* starting at position <code>pos</code>. Characters written to the stream
* will overwrite the existing characters
* in the <code>Clob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Clob</code> value is reached
* while writing characters to the stream, then the length of the <code>Clob</code>
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>CLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to this
* <code>CLOB</code> object; The first position is 1
* @return the stream to which ASCII encoded characters can be written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getAsciiStream
*
* @since 1.4
*/
java.io.OutputStream setAsciiStream(long pos) throws SQLException;
/**
* Retrieves a stream to be used to write a stream of Unicode characters
* to the <code>CLOB</code> value that this <code>Clob</code> object
* represents, at position <code>pos</code>. Characters written to the stream
* will overwrite the existing characters
* in the <code>Clob</code> object starting at the position
* <code>pos</code>. If the end of the <code>Clob</code> value is reached
* while writing characters to the stream, then the length of the <code>Clob</code>
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>CLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to the
* <code>CLOB</code> value; The first position is 1
*
* @return a stream to which Unicode encoded characters can be written
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if pos is less than 1
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see #getCharacterStream
*
* @since 1.4
*/
java.io.Writer setCharacterStream(long pos) throws SQLException;
/**
* Truncates the <code>CLOB</code> value that this <code>Clob</code>
* designates to have a length of <code>len</code>
* characters.
* <p>
* <b>Note:</b> If the value specified for <code>pos</code>
* is greater then the length+1 of the <code>CLOB</code> value then the
* behavior is undefined. Some JDBC drivers may throw a
* <code>SQLException</code> while other drivers may support this
* operation.
*
* @param len the length, in characters, to which the <code>CLOB</code> value
* should be truncated
* @exception SQLException if there is an error accessing the
* <code>CLOB</code> value or if len is less than 0
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void truncate(long len) throws SQLException;
/**
* This method frees the <code>Clob</code> object and releases the resources the resources
* that it holds. The object is invalid once the <code>free</code> method
* is called.
* <p>
* After <code>free</code> has been called, any attempt to invoke a
* method other than <code>free</code> will result in a <code>SQLException</code>
* being thrown. If <code>free</code> is called multiple times, the subsequent
* calls to <code>free</code> are treated as a no-op.
* <p>
* @throws SQLException if an error occurs releasing
* the Clob's resources
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void free() throws SQLException;
/**
* Returns a <code>Reader</code> object that contains a partial <code>Clob</code> value, starting
* with the character specified by pos, which is length characters in length.
*
* @param pos the offset to the first character of the partial value to
* be retrieved. The first character in the Clob is at position 1.
* @param length the length in characters of the partial value to be retrieved.
* @return <code>Reader</code> through which the partial <code>Clob</code> value can be read.
* @throws SQLException if pos is less than 1 or if pos is greater than the number of
* characters in the <code>Clob</code> or if pos + length is greater than the number of
* characters in the <code>Clob</code>
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
Reader getCharacterStream(long pos, long length) throws SQLException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,188 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An exception thrown as a <code>DataTruncation</code> exception
* (on writes) or reported as a
* <code>DataTruncation</code> warning (on reads)
* when a data values is unexpectedly truncated for reasons other than its having
* exceeded <code>MaxFieldSize</code>.
*
* <P>The SQLstate for a <code>DataTruncation</code> during read is <code>01004</code>.
* <P>The SQLstate for a <code>DataTruncation</code> during write is <code>22001</code>.
*/
public class DataTruncation extends SQLWarning {
/**
* Creates a <code>DataTruncation</code> object
* with the SQLState initialized
* to 01004 when <code>read</code> is set to <code>true</code> and 22001
* when <code>read</code> is set to <code>false</code>,
* the reason set to "Data truncation", the
* vendor code set to 0, and
* the other fields set to the given values.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param index The index of the parameter or column value
* @param parameter true if a parameter value was truncated
* @param read true if a read was truncated
* @param dataSize the original size of the data
* @param transferSize the size after truncation
*/
public DataTruncation(int index, boolean parameter,
boolean read, int dataSize,
int transferSize) {
super("Data truncation", read == true?"01004":"22001");
this.index = index;
this.parameter = parameter;
this.read = read;
this.dataSize = dataSize;
this.transferSize = transferSize;
}
/**
* Creates a <code>DataTruncation</code> object
* with the SQLState initialized
* to 01004 when <code>read</code> is set to <code>true</code> and 22001
* when <code>read</code> is set to <code>false</code>,
* the reason set to "Data truncation", the
* vendor code set to 0, and
* the other fields set to the given values.
* <p>
*
* @param index The index of the parameter or column value
* @param parameter true if a parameter value was truncated
* @param read true if a read was truncated
* @param dataSize the original size of the data
* @param transferSize the size after truncation
* @param cause the underlying reason for this <code>DataTruncation</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
*
* @since 1.6
*/
public DataTruncation(int index, boolean parameter,
boolean read, int dataSize,
int transferSize, Throwable cause) {
super("Data truncation", read == true?"01004":"22001",cause);
this.index = index;
this.parameter = parameter;
this.read = read;
this.dataSize = dataSize;
this.transferSize = transferSize;
}
/**
* Retrieves the index of the column or parameter that was truncated.
*
* <P>This may be -1 if the column or parameter index is unknown, in
* which case the <code>parameter</code> and <code>read</code> fields should be ignored.
*
* @return the index of the truncated parameter or column value
*/
public int getIndex() {
return index;
}
/**
* Indicates whether the value truncated was a parameter value or
* a column value.
*
* @return <code>true</code> if the value truncated was a parameter;
* <code>false</code> if it was a column value
*/
public boolean getParameter() {
return parameter;
}
/**
* Indicates whether or not the value was truncated on a read.
*
* @return <code>true</code> if the value was truncated when read from
* the database; <code>false</code> if the data was truncated on a write
*/
public boolean getRead() {
return read;
}
/**
* Gets the number of bytes of data that should have been transferred.
* This number may be approximate if data conversions were being
* performed. The value may be <code>-1</code> if the size is unknown.
*
* @return the number of bytes of data that should have been transferred
*/
public int getDataSize() {
return dataSize;
}
/**
* Gets the number of bytes of data actually transferred.
* The value may be <code>-1</code> if the size is unknown.
*
* @return the number of bytes of data actually transferred
*/
public int getTransferSize() {
return transferSize;
}
/**
* @serial
*/
private int index;
/**
* @serial
*/
private boolean parameter;
/**
* @serial
*/
private boolean read;
/**
* @serial
*/
private int dataSize;
/**
* @serial
*/
private int transferSize;
/**
* @serial
*/
private static final long serialVersionUID = 6464298989504059473L;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.time.Instant;
import java.time.LocalDate;
/**
* <P>A thin wrapper around a millisecond value that allows
* JDBC to identify this as an SQL <code>DATE</code> value. A
* milliseconds value represents the number of milliseconds that
* have passed since January 1, 1970 00:00:00.000 GMT.
* <p>
* To conform with the definition of SQL <code>DATE</code>, the
* millisecond values wrapped by a <code>java.sql.Date</code> instance
* must be 'normalized' by setting the
* hours, minutes, seconds, and milliseconds to zero in the particular
* time zone with which the instance is associated.
*/
public class Date extends java.util.Date {
/**
* Constructs a <code>Date</code> object initialized with the given
* year, month, and day.
* <P>
* The result is undefined if a given argument is out of bounds.
*
* @param year the year minus 1900; must be 0 to 8099. (Note that
* 8099 is 9999 minus 1900.)
* @param month 0 to 11
* @param day 1 to 31
* @deprecated instead use the constructor <code>Date(long date)</code>
*/
@Deprecated
public Date(int year, int month, int day) {
super(year, month, day);
}
/**
* Constructs a <code>Date</code> object using the given milliseconds
* time value. If the given milliseconds value contains time
* information, the driver will set the time components to the
* time in the default time zone (the time zone of the Java virtual
* machine running the application) that corresponds to zero GMT.
*
* @param date milliseconds since January 1, 1970, 00:00:00 GMT not
* to exceed the milliseconds representation for the year 8099.
* A negative number indicates the number of milliseconds
* before January 1, 1970, 00:00:00 GMT.
*/
public Date(long date) {
// If the millisecond date value contains time info, mask it out.
super(date);
}
/**
* Sets an existing <code>Date</code> object
* using the given milliseconds time value.
* If the given milliseconds value contains time information,
* the driver will set the time components to the
* time in the default time zone (the time zone of the Java virtual
* machine running the application) that corresponds to zero GMT.
*
* @param date milliseconds since January 1, 1970, 00:00:00 GMT not
* to exceed the milliseconds representation for the year 8099.
* A negative number indicates the number of milliseconds
* before January 1, 1970, 00:00:00 GMT.
*/
public void setTime(long date) {
// If the millisecond date value contains time info, mask it out.
super.setTime(date);
}
/**
* Converts a string in JDBC date escape format to
* a <code>Date</code> value.
*
* @param s a <code>String</code> object representing a date in
* in the format "yyyy-[m]m-[d]d". The leading zero for <code>mm</code>
* and <code>dd</code> may also be omitted.
* @return a <code>java.sql.Date</code> object representing the
* given date
* @throws IllegalArgumentException if the date given is not in the
* JDBC date escape format (yyyy-[m]m-[d]d)
*/
public static Date valueOf(String s) {
final int YEAR_LENGTH = 4;
final int MONTH_LENGTH = 2;
final int DAY_LENGTH = 2;
final int MAX_MONTH = 12;
final int MAX_DAY = 31;
int firstDash;
int secondDash;
Date d = null;
if (s == null) {
throw new java.lang.IllegalArgumentException();
}
firstDash = s.indexOf('-');
secondDash = s.indexOf('-', firstDash + 1);
if ((firstDash > 0) && (secondDash > 0) && (secondDash < s.length() - 1)) {
String yyyy = s.substring(0, firstDash);
String mm = s.substring(firstDash + 1, secondDash);
String dd = s.substring(secondDash + 1);
if (yyyy.length() == YEAR_LENGTH &&
(mm.length() >= 1 && mm.length() <= MONTH_LENGTH) &&
(dd.length() >= 1 && dd.length() <= DAY_LENGTH)) {
int year = Integer.parseInt(yyyy);
int month = Integer.parseInt(mm);
int day = Integer.parseInt(dd);
if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
d = new Date(year - 1900, month - 1, day);
}
}
}
if (d == null) {
throw new java.lang.IllegalArgumentException();
}
return d;
}
/**
* Formats a date in the date escape format yyyy-mm-dd.
* <P>
* @return a String in yyyy-mm-dd format
*/
@SuppressWarnings("deprecation")
public String toString () {
int year = super.getYear() + 1900;
int month = super.getMonth() + 1;
int day = super.getDate();
char buf[] = "2000-00-00".toCharArray();
buf[0] = Character.forDigit(year/1000,10);
buf[1] = Character.forDigit((year/100)%10,10);
buf[2] = Character.forDigit((year/10)%10,10);
buf[3] = Character.forDigit(year%10,10);
buf[5] = Character.forDigit(month/10,10);
buf[6] = Character.forDigit(month%10,10);
buf[8] = Character.forDigit(day/10,10);
buf[9] = Character.forDigit(day%10,10);
return new String(buf);
}
// Override all the time operations inherited from java.util.Date;
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setHours
*/
@Deprecated
public int getHours() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setMinutes
*/
@Deprecated
public int getMinutes() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #setSeconds
*/
@Deprecated
public int getSeconds() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getHours
*/
@Deprecated
public void setHours(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getMinutes
*/
@Deprecated
public void setMinutes(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL Date
* values do not have a time component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this method is invoked
* @see #getSeconds
*/
@Deprecated
public void setSeconds(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = 1511598038487230103L;
/**
* Obtains an instance of {@code Date} from a {@link LocalDate} object
* with the same year, month and day of month value as the given
* {@code LocalDate}.
* <p>
* The provided {@code LocalDate} is interpreted as the local date
* in the local time zone.
*
* @param date a {@code LocalDate} to convert
* @return a {@code Date} object
* @exception NullPointerException if {@code date} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Date valueOf(LocalDate date) {
return new Date(date.getYear() - 1900, date.getMonthValue() -1,
date.getDayOfMonth());
}
/**
* Converts this {@code Date} object to a {@code LocalDate}
* <p>
* The conversion creates a {@code LocalDate} that represents the same
* date value as this {@code Date} in local time zone
*
* @return a {@code LocalDate} object representing the same date value
*
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalDate toLocalDate() {
return LocalDate.of(getYear() + 1900, getMonth() + 1, getDate());
}
/**
* This method always throws an UnsupportedOperationException and should
* not be used because SQL {@code Date} values do not have a time
* component.
*
* @exception java.lang.UnsupportedOperationException if this method is invoked
*/
@Override
public Instant toInstant() {
throw new java.lang.UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.logging.Logger;
/**
* The interface that every driver class must implement.
* <P>The Java SQL framework allows for multiple database drivers.
*
* <P>Each driver should supply a class that implements
* the Driver interface.
*
* <P>The DriverManager will try to load as many drivers as it can
* find and then for any given connection request, it will ask each
* driver in turn to try to connect to the target URL.
*
* <P>It is strongly recommended that each Driver class should be
* small and standalone so that the Driver class can be loaded and
* queried without bringing in vast quantities of supporting code.
*
* <P>When a Driver class is loaded, it should create an instance of
* itself and register it with the DriverManager. This means that a
* user can load and register a driver by calling:
* <p>
* {@code Class.forName("foo.bah.Driver")}
* <p>
* A JDBC driver may create a {@linkplain DriverAction} implementation in order
* to receive notifications when {@linkplain DriverManager#deregisterDriver} has
* been called.
* @see DriverManager
* @see Connection
* @see DriverAction
*/
public interface Driver {
/**
* Attempts to make a database connection to the given URL.
* The driver should return "null" if it realizes it is the wrong kind
* of driver to connect to the given URL. This will be common, as when
* the JDBC driver manager is asked to connect to a given URL it passes
* the URL to each loaded driver in turn.
*
* <P>The driver should throw an <code>SQLException</code> if it is the right
* driver to connect to the given URL but has trouble connecting to
* the database.
*
* <P>The {@code Properties} argument can be used to pass
* arbitrary string tag/value pairs as connection arguments.
* Normally at least "user" and "password" properties should be
* included in the {@code Properties} object.
* <p>
* <B>Note:</B> If a property is specified as part of the {@code url} and
* is also specified in the {@code Properties} object, it is
* implementation-defined as to which value will take precedence. For
* maximum portability, an application should only specify a property once.
*
* @param url the URL of the database to which to connect
* @param info a list of arbitrary string tag/value pairs as
* connection arguments. Normally at least a "user" and
* "password" property should be included.
* @return a <code>Connection</code> object that represents a
* connection to the URL
* @exception SQLException if a database access error occurs or the url is
* {@code null}
*/
Connection connect(String url, java.util.Properties info)
throws SQLException;
/**
* Retrieves whether the driver thinks that it can open a connection
* to the given URL. Typically drivers will return <code>true</code> if they
* understand the sub-protocol specified in the URL and <code>false</code> if
* they do not.
*
* @param url the URL of the database
* @return <code>true</code> if this driver understands the given URL;
* <code>false</code> otherwise
* @exception SQLException if a database access error occurs or the url is
* {@code null}
*/
boolean acceptsURL(String url) throws SQLException;
/**
* Gets information about the possible properties for this driver.
* <P>
* The <code>getPropertyInfo</code> method is intended to allow a generic
* GUI tool to discover what properties it should prompt
* a human for in order to get
* enough information to connect to a database. Note that depending on
* the values the human has supplied so far, additional values may become
* necessary, so it may be necessary to iterate though several calls
* to the <code>getPropertyInfo</code> method.
*
* @param url the URL of the database to which to connect
* @param info a proposed list of tag/value pairs that will be sent on
* connect open
* @return an array of <code>DriverPropertyInfo</code> objects describing
* possible properties. This array may be an empty array if
* no properties are required.
* @exception SQLException if a database access error occurs
*/
DriverPropertyInfo[] getPropertyInfo(String url, java.util.Properties info)
throws SQLException;
/**
* Retrieves the driver's major version number. Initially this should be 1.
*
* @return this driver's major version number
*/
int getMajorVersion();
/**
* Gets the driver's minor version number. Initially this should be 0.
* @return this driver's minor version number
*/
int getMinorVersion();
/**
* Reports whether this driver is a genuine JDBC
* Compliant&trade; driver.
* A driver may only report <code>true</code> here if it passes the JDBC
* compliance tests; otherwise it is required to return <code>false</code>.
* <P>
* JDBC compliance requires full support for the JDBC API and full support
* for SQL 92 Entry Level. It is expected that JDBC compliant drivers will
* be available for all the major commercial databases.
* <P>
* This method is not intended to encourage the development of non-JDBC
* compliant drivers, but is a recognition of the fact that some vendors
* are interested in using the JDBC API and framework for lightweight
* databases that do not support full database functionality, or for
* special databases such as document information retrieval where a SQL
* implementation may not be feasible.
* @return <code>true</code> if this driver is JDBC Compliant; <code>false</code>
* otherwise
*/
boolean jdbcCompliant();
//------------------------- JDBC 4.1 -----------------------------------
/**
* Return the parent Logger of all the Loggers used by this driver. This
* should be the Logger farthest from the root Logger that is
* still an ancestor of all of the Loggers used by this driver. Configuring
* this Logger will affect all of the log messages generated by the driver.
* In the worst case, this may be the root Logger.
*
* @return the parent Logger for this driver
* @throws SQLFeatureNotSupportedException if the driver does not use
* {@code java.util.logging}.
* @since 1.7
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException;
}

View File

@@ -0,0 +1,66 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An interface that must be implemented when a {@linkplain Driver} wants to be
* notified by {@code DriverManager}.
*<P>
* A {@code DriverAction} implementation is not intended to be used
* directly by applications. A JDBC Driver may choose
* to create its {@code DriverAction} implementation in a private class
* to avoid it being called directly.
* <p>
* The JDBC driver's static initialization block must call
* {@linkplain DriverManager#registerDriver(java.sql.Driver, java.sql.DriverAction) } in order
* to inform {@code DriverManager} which {@code DriverAction} implementation to
* call when the JDBC driver is de-registered.
* @since 1.8
*/
public interface DriverAction {
/**
* Method called by
* {@linkplain DriverManager#deregisterDriver(Driver) }
* to notify the JDBC driver that it was de-registered.
* <p>
* The {@code deregister} method is intended only to be used by JDBC Drivers
* and not by applications. JDBC drivers are recommended to not implement
* {@code DriverAction} in a public class. If there are active
* connections to the database at the time that the {@code deregister}
* method is called, it is implementation specific as to whether the
* connections are closed or allowed to continue. Once this method is
* called, it is implementation specific as to whether the driver may
* limit the ability to create new connections to the database, invoke
* other {@code Driver} methods or throw a {@code SQLException}.
* Consult your JDBC driver's documentation for additional information
* on its behavior.
* @see DriverManager#registerDriver(java.sql.Driver, java.sql.DriverAction)
* @see DriverManager#deregisterDriver(Driver)
* @since 1.8
*/
void deregister();
}

View File

@@ -0,0 +1,728 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.CopyOnWriteArrayList;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
/**
* <P>The basic service for managing a set of JDBC drivers.<br>
* <B>NOTE:</B> The {@link javax.sql.DataSource} interface, new in the
* JDBC 2.0 API, provides another way to connect to a data source.
* The use of a <code>DataSource</code> object is the preferred means of
* connecting to a data source.
*
* <P>As part of its initialization, the <code>DriverManager</code> class will
* attempt to load the driver classes referenced in the "jdbc.drivers"
* system property. This allows a user to customize the JDBC Drivers
* used by their applications. For example in your
* ~/.hotjava/properties file you might specify:
* <pre>
* <CODE>jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver</CODE>
* </pre>
*<P> The <code>DriverManager</code> methods <code>getConnection</code> and
* <code>getDrivers</code> have been enhanced to support the Java Standard Edition
* <a href="../../../technotes/guides/jar/jar.html#Service%20Provider">Service Provider</a> mechanism. JDBC 4.0 Drivers must
* include the file <code>META-INF/services/java.sql.Driver</code>. This file contains the name of the JDBC drivers
* implementation of <code>java.sql.Driver</code>. For example, to load the <code>my.sql.Driver</code> class,
* the <code>META-INF/services/java.sql.Driver</code> file would contain the entry:
* <pre>
* <code>my.sql.Driver</code>
* </pre>
*
* <P>Applications no longer need to explicitly load JDBC drivers using <code>Class.forName()</code>. Existing programs
* which currently load JDBC drivers using <code>Class.forName()</code> will continue to work without
* modification.
*
* <P>When the method <code>getConnection</code> is called,
* the <code>DriverManager</code> will attempt to
* locate a suitable driver from amongst those loaded at
* initialization and those loaded explicitly using the same classloader
* as the current applet or application.
*
* <P>
* Starting with the Java 2 SDK, Standard Edition, version 1.3, a
* logging stream can be set only if the proper
* permission has been granted. Normally this will be done with
* the tool PolicyTool, which can be used to grant <code>permission
* java.sql.SQLPermission "setLog"</code>.
* @see Driver
* @see Connection
*/
public class DriverManager {
// List of registered JDBC drivers
private final static CopyOnWriteArrayList<DriverInfo> registeredDrivers = new CopyOnWriteArrayList<>();
private static volatile int loginTimeout = 0;
private static volatile java.io.PrintWriter logWriter = null;
private static volatile java.io.PrintStream logStream = null;
// Used in println() to synchronize logWriter
private final static Object logSync = new Object();
/* Prevent the DriverManager class from being instantiated. */
private DriverManager(){}
/**
* Load the initial JDBC drivers by checking the System property
* jdbc.properties and then use the {@code ServiceLoader} mechanism
*/
static {
loadInitialDrivers();
println("JDBC DriverManager initialized");
}
/**
* The <code>SQLPermission</code> constant that allows the
* setting of the logging stream.
* @since 1.3
*/
final static SQLPermission SET_LOG_PERMISSION =
new SQLPermission("setLog");
/**
* The {@code SQLPermission} constant that allows the
* un-register a registered JDBC driver.
* @since 1.8
*/
final static SQLPermission DEREGISTER_DRIVER_PERMISSION =
new SQLPermission("deregisterDriver");
//--------------------------JDBC 2.0-----------------------------
/**
* Retrieves the log writer.
*
* The <code>getLogWriter</code> and <code>setLogWriter</code>
* methods should be used instead
* of the <code>get/setlogStream</code> methods, which are deprecated.
* @return a <code>java.io.PrintWriter</code> object
* @see #setLogWriter
* @since 1.2
*/
public static java.io.PrintWriter getLogWriter() {
return logWriter;
}
/**
* Sets the logging/tracing <code>PrintWriter</code> object
* that is used by the <code>DriverManager</code> and all drivers.
* <P>
* There is a minor versioning problem created by the introduction
* of the method <code>setLogWriter</code>. The
* method <code>setLogWriter</code> cannot create a <code>PrintStream</code> object
* that will be returned by <code>getLogStream</code>---the Java platform does
* not provide a backward conversion. As a result, a new application
* that uses <code>setLogWriter</code> and also uses a JDBC 1.0 driver that uses
* <code>getLogStream</code> will likely not see debugging information written
* by that driver.
*<P>
* Starting with the Java 2 SDK, Standard Edition, version 1.3 release, this method checks
* to see that there is an <code>SQLPermission</code> object before setting
* the logging stream. If a <code>SecurityManager</code> exists and its
* <code>checkPermission</code> method denies setting the log writer, this
* method throws a <code>java.lang.SecurityException</code>.
*
* @param out the new logging/tracing <code>PrintStream</code> object;
* <code>null</code> to disable logging and tracing
* @throws SecurityException
* if a security manager exists and its
* <code>checkPermission</code> method denies
* setting the log writer
*
* @see SecurityManager#checkPermission
* @see #getLogWriter
* @since 1.2
*/
public static void setLogWriter(java.io.PrintWriter out) {
SecurityManager sec = System.getSecurityManager();
if (sec != null) {
sec.checkPermission(SET_LOG_PERMISSION);
}
logStream = null;
logWriter = out;
}
//---------------------------------------------------------------
/**
* Attempts to establish a connection to the given database URL.
* The <code>DriverManager</code> attempts to select an appropriate driver from
* the set of registered JDBC drivers.
*<p>
* <B>Note:</B> If a property is specified as part of the {@code url} and
* is also specified in the {@code Properties} object, it is
* implementation-defined as to which value will take precedence.
* For maximum portability, an application should only specify a
* property once.
*
* @param url a database url of the form
* <code> jdbc:<em>subprotocol</em>:<em>subname</em></code>
* @param info a list of arbitrary string tag/value pairs as
* connection arguments; normally at least a "user" and
* "password" property should be included
* @return a Connection to the URL
* @exception SQLException if a database access error occurs or the url is
* {@code null}
* @throws SQLTimeoutException when the driver has determined that the
* timeout value specified by the {@code setLoginTimeout} method
* has been exceeded and has at least tried to cancel the
* current database connection attempt
*/
@CallerSensitive
public static Connection getConnection(String url,
java.util.Properties info) throws SQLException {
return (getConnection(url, info, Reflection.getCallerClass()));
}
/**
* Attempts to establish a connection to the given database URL.
* The <code>DriverManager</code> attempts to select an appropriate driver from
* the set of registered JDBC drivers.
*<p>
* <B>Note:</B> If the {@code user} or {@code password} property are
* also specified as part of the {@code url}, it is
* implementation-defined as to which value will take precedence.
* For maximum portability, an application should only specify a
* property once.
*
* @param url a database url of the form
* <code>jdbc:<em>subprotocol</em>:<em>subname</em></code>
* @param user the database user on whose behalf the connection is being
* made
* @param password the user's password
* @return a connection to the URL
* @exception SQLException if a database access error occurs or the url is
* {@code null}
* @throws SQLTimeoutException when the driver has determined that the
* timeout value specified by the {@code setLoginTimeout} method
* has been exceeded and has at least tried to cancel the
* current database connection attempt
*/
@CallerSensitive
public static Connection getConnection(String url,
String user, String password) throws SQLException {
java.util.Properties info = new java.util.Properties();
if (user != null) {
info.put("user", user);
}
if (password != null) {
info.put("password", password);
}
return (getConnection(url, info, Reflection.getCallerClass()));
}
/**
* Attempts to establish a connection to the given database URL.
* The <code>DriverManager</code> attempts to select an appropriate driver from
* the set of registered JDBC drivers.
*
* @param url a database url of the form
* <code> jdbc:<em>subprotocol</em>:<em>subname</em></code>
* @return a connection to the URL
* @exception SQLException if a database access error occurs or the url is
* {@code null}
* @throws SQLTimeoutException when the driver has determined that the
* timeout value specified by the {@code setLoginTimeout} method
* has been exceeded and has at least tried to cancel the
* current database connection attempt
*/
@CallerSensitive
public static Connection getConnection(String url)
throws SQLException {
java.util.Properties info = new java.util.Properties();
return (getConnection(url, info, Reflection.getCallerClass()));
}
/**
* Attempts to locate a driver that understands the given URL.
* The <code>DriverManager</code> attempts to select an appropriate driver from
* the set of registered JDBC drivers.
*
* @param url a database URL of the form
* <code>jdbc:<em>subprotocol</em>:<em>subname</em></code>
* @return a <code>Driver</code> object representing a driver
* that can connect to the given URL
* @exception SQLException if a database access error occurs
*/
@CallerSensitive
public static Driver getDriver(String url)
throws SQLException {
println("DriverManager.getDriver(\"" + url + "\")");
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers attempting to locate someone
// who understands the given URL.
for (DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClass)) {
try {
if(aDriver.driver.acceptsURL(url)) {
// Success!
println("getDriver returning " + aDriver.driver.getClass().getName());
return (aDriver.driver);
}
} catch(SQLException sqe) {
// Drop through and try the next driver.
}
} else {
println(" skipping: " + aDriver.driver.getClass().getName());
}
}
println("getDriver: no suitable driver");
throw new SQLException("No suitable driver", "08001");
}
/**
* Registers the given driver with the {@code DriverManager}.
* A newly-loaded driver class should call
* the method {@code registerDriver} to make itself
* known to the {@code DriverManager}. If the driver is currently
* registered, no action is taken.
*
* @param driver the new JDBC Driver that is to be registered with the
* {@code DriverManager}
* @exception SQLException if a database access error occurs
* @exception NullPointerException if {@code driver} is null
*/
public static synchronized void registerDriver(java.sql.Driver driver)
throws SQLException {
registerDriver(driver, null);
}
/**
* Registers the given driver with the {@code DriverManager}.
* A newly-loaded driver class should call
* the method {@code registerDriver} to make itself
* known to the {@code DriverManager}. If the driver is currently
* registered, no action is taken.
*
* @param driver the new JDBC Driver that is to be registered with the
* {@code DriverManager}
* @param da the {@code DriverAction} implementation to be used when
* {@code DriverManager#deregisterDriver} is called
* @exception SQLException if a database access error occurs
* @exception NullPointerException if {@code driver} is null
* @since 1.8
*/
public static synchronized void registerDriver(java.sql.Driver driver,
DriverAction da)
throws SQLException {
/* Register the driver if it has not already been added to our list */
if(driver != null) {
registeredDrivers.addIfAbsent(new DriverInfo(driver, da));
} else {
// This is for compatibility with the original DriverManager
throw new NullPointerException();
}
println("registerDriver: " + driver);
}
/**
* Removes the specified driver from the {@code DriverManager}'s list of
* registered drivers.
* <p>
* If a {@code null} value is specified for the driver to be removed, then no
* action is taken.
* <p>
* If a security manager exists and its {@code checkPermission} denies
* permission, then a {@code SecurityException} will be thrown.
* <p>
* If the specified driver is not found in the list of registered drivers,
* then no action is taken. If the driver was found, it will be removed
* from the list of registered drivers.
* <p>
* If a {@code DriverAction} instance was specified when the JDBC driver was
* registered, its deregister method will be called
* prior to the driver being removed from the list of registered drivers.
*
* @param driver the JDBC Driver to remove
* @exception SQLException if a database access error occurs
* @throws SecurityException if a security manager exists and its
* {@code checkPermission} method denies permission to deregister a driver.
*
* @see SecurityManager#checkPermission
*/
@CallerSensitive
public static synchronized void deregisterDriver(Driver driver)
throws SQLException {
if (driver == null) {
return;
}
SecurityManager sec = System.getSecurityManager();
if (sec != null) {
sec.checkPermission(DEREGISTER_DRIVER_PERMISSION);
}
println("DriverManager.deregisterDriver: " + driver);
DriverInfo aDriver = new DriverInfo(driver, null);
if(registeredDrivers.contains(aDriver)) {
if (isDriverAllowed(driver, Reflection.getCallerClass())) {
DriverInfo di = registeredDrivers.get(registeredDrivers.indexOf(aDriver));
// If a DriverAction was specified, Call it to notify the
// driver that it has been deregistered
if(di.action() != null) {
di.action().deregister();
}
registeredDrivers.remove(aDriver);
} else {
// If the caller does not have permission to load the driver then
// throw a SecurityException.
throw new SecurityException();
}
} else {
println(" couldn't find driver to unload");
}
}
/**
* Retrieves an Enumeration with all of the currently loaded JDBC drivers
* to which the current caller has access.
*
* <P><B>Note:</B> The classname of a driver can be found using
* <CODE>d.getClass().getName()</CODE>
*
* @return the list of JDBC Drivers loaded by the caller's class loader
*/
@CallerSensitive
public static java.util.Enumeration<Driver> getDrivers() {
java.util.Vector<Driver> result = new java.util.Vector<>();
Class<?> callerClass = Reflection.getCallerClass();
// Walk through the loaded registeredDrivers.
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerClass)) {
result.addElement(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return (result.elements());
}
/**
* Sets the maximum time in seconds that a driver will wait
* while attempting to connect to a database once the driver has
* been identified.
*
* @param seconds the login time limit in seconds; zero means there is no limit
* @see #getLoginTimeout
*/
public static void setLoginTimeout(int seconds) {
loginTimeout = seconds;
}
/**
* Gets the maximum time in seconds that a driver can wait
* when attempting to log in to a database.
*
* @return the driver login time limit in seconds
* @see #setLoginTimeout
*/
public static int getLoginTimeout() {
return (loginTimeout);
}
/**
* Sets the logging/tracing PrintStream that is used
* by the <code>DriverManager</code>
* and all drivers.
*<P>
* In the Java 2 SDK, Standard Edition, version 1.3 release, this method checks
* to see that there is an <code>SQLPermission</code> object before setting
* the logging stream. If a <code>SecurityManager</code> exists and its
* <code>checkPermission</code> method denies setting the log writer, this
* method throws a <code>java.lang.SecurityException</code>.
*
* @param out the new logging/tracing PrintStream; to disable, set to <code>null</code>
* @deprecated Use {@code setLogWriter}
* @throws SecurityException if a security manager exists and its
* <code>checkPermission</code> method denies setting the log stream
*
* @see SecurityManager#checkPermission
* @see #getLogStream
*/
@Deprecated
public static void setLogStream(java.io.PrintStream out) {
SecurityManager sec = System.getSecurityManager();
if (sec != null) {
sec.checkPermission(SET_LOG_PERMISSION);
}
logStream = out;
if ( out != null )
logWriter = new java.io.PrintWriter(out);
else
logWriter = null;
}
/**
* Retrieves the logging/tracing PrintStream that is used by the <code>DriverManager</code>
* and all drivers.
*
* @return the logging/tracing PrintStream; if disabled, is <code>null</code>
* @deprecated Use {@code getLogWriter}
* @see #setLogStream
*/
@Deprecated
public static java.io.PrintStream getLogStream() {
return logStream;
}
/**
* Prints a message to the current JDBC log stream.
*
* @param message a log or tracing message
*/
public static void println(String message) {
synchronized (logSync) {
if (logWriter != null) {
logWriter.println(message);
// automatic flushing is never enabled, so we must do it ourselves
logWriter.flush();
}
}
}
//------------------------------------------------------------------------
// Indicates whether the class object that would be created if the code calling
// DriverManager is accessible.
private static boolean isDriverAllowed(Driver driver, Class<?> caller) {
ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
return isDriverAllowed(driver, callerCL);
}
private static boolean isDriverAllowed(Driver driver, ClassLoader classLoader) {
boolean result = false;
if(driver != null) {
Class<?> aClass = null;
try {
aClass = Class.forName(driver.getClass().getName(), true, classLoader);
} catch (Exception ex) {
result = false;
}
result = ( aClass == driver.getClass() ) ? true : false;
}
return result;
}
private static void loadInitialDrivers() {
String drivers;
try {
drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty("jdbc.drivers");
}
});
} catch (Exception ex) {
drivers = null;
}
// If the driver is packaged as a Service Provider, load it.
// Get all the drivers through the classloader
// exposed as a java.sql.Driver.class service.
// ServiceLoader.load() replaces the sun.misc.Providers()
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
ServiceLoader<Driver> loadedDrivers = ServiceLoader.load(Driver.class);
Iterator<Driver> driversIterator = loadedDrivers.iterator();
/* Load these drivers, so that they can be instantiated.
* It may be the case that the driver class may not be there
* i.e. there may be a packaged driver with the service class
* as implementation of java.sql.Driver but the actual class
* may be missing. In that case a java.util.ServiceConfigurationError
* will be thrown at runtime by the VM trying to locate
* and load the service.
*
* Adding a try catch block to catch those runtime errors
* if driver not available in classpath but it's
* packaged as service and that service is there in classpath.
*/
try{
while(driversIterator.hasNext()) {
driversIterator.next();
}
} catch(Throwable t) {
// Do nothing
}
return null;
}
});
println("DriverManager.initialize: jdbc.drivers = " + drivers);
if (drivers == null || drivers.equals("")) {
return;
}
String[] driversList = drivers.split(":");
println("number of Drivers:" + driversList.length);
for (String aDriver : driversList) {
try {
println("DriverManager.Initialize: loading " + aDriver);
Class.forName(aDriver, true,
ClassLoader.getSystemClassLoader());
} catch (Exception ex) {
println("DriverManager.Initialize: load failed: " + ex);
}
}
}
// Worker method called by the public getConnection() methods.
private static Connection getConnection(
String url, java.util.Properties info, Class<?> caller) throws SQLException {
/*
* When callerCl is null, we should check the application's
* (which is invoking this class indirectly)
* classloader, so that the JDBC driver class outside rt.jar
* can be loaded from here.
*/
ClassLoader callerCL = caller != null ? caller.getClassLoader() : null;
synchronized(DriverManager.class) {
// synchronize loading of the correct classloader.
if (callerCL == null) {
callerCL = Thread.currentThread().getContextClassLoader();
}
}
if(url == null) {
throw new SQLException("The url cannot be null", "08001");
}
println("DriverManager.getConnection(\"" + url + "\")");
// Walk through the loaded registeredDrivers attempting to make a connection.
// Remember the first exception that gets raised so we can reraise it.
SQLException reason = null;
for(DriverInfo aDriver : registeredDrivers) {
// If the caller does not have permission to load the driver then
// skip it.
if(isDriverAllowed(aDriver.driver, callerCL)) {
try {
println(" trying " + aDriver.driver.getClass().getName());
Connection con = aDriver.driver.connect(url, info);
if (con != null) {
// Success!
println("getConnection returning " + aDriver.driver.getClass().getName());
return (con);
}
} catch (SQLException ex) {
if (reason == null) {
reason = ex;
}
}
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
// if we got here nobody could connect.
if (reason != null) {
println("getConnection failed: " + reason);
throw reason;
}
println("getConnection: no suitable driver found for "+ url);
throw new SQLException("No suitable driver found for "+ url, "08001");
}
}
/*
* Wrapper class for registered Drivers in order to not expose Driver.equals()
* to avoid the capture of the Driver it being compared to as it might not
* normally have access.
*/
class DriverInfo {
final Driver driver;
DriverAction da;
DriverInfo(Driver driver, DriverAction action) {
this.driver = driver;
da = action;
}
@Override
public boolean equals(Object other) {
return (other instanceof DriverInfo)
&& this.driver == ((DriverInfo) other).driver;
}
@Override
public int hashCode() {
return driver.hashCode();
}
@Override
public String toString() {
return ("driver[className=" + driver + "]");
}
DriverAction action() {
return da;
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <p>Driver properties for making a connection. The
* <code>DriverPropertyInfo</code> class is of interest only to advanced programmers
* who need to interact with a Driver via the method
* <code>getDriverProperties</code> to discover
* and supply properties for connections.
*/
public class DriverPropertyInfo {
/**
* Constructs a <code>DriverPropertyInfo</code> object with a given
* name and value. The <code>description</code> and <code>choices</code>
* are initialized to <code>null</code> and <code>required</code> is initialized
* to <code>false</code>.
*
* @param name the name of the property
* @param value the current value, which may be null
*/
public DriverPropertyInfo(String name, String value) {
this.name = name;
this.value = value;
}
/**
* The name of the property.
*/
public String name;
/**
* A brief description of the property, which may be null.
*/
public String description = null;
/**
* The <code>required</code> field is <code>true</code> if a value must be
* supplied for this property
* during <code>Driver.connect</code> and <code>false</code> otherwise.
*/
public boolean required = false;
/**
* The <code>value</code> field specifies the current value of
* the property, based on a combination of the information
* supplied to the method <code>getPropertyInfo</code>, the
* Java environment, and the driver-supplied default values. This field
* may be null if no value is known.
*/
public String value = null;
/**
* An array of possible values if the value for the field
* <code>DriverPropertyInfo.value</code> may be selected
* from a particular set of values; otherwise null.
*/
public String[] choices = null;
}

View File

@@ -0,0 +1,261 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <P>Defines the constants that are used to identify generic
* SQL types, called JDBC types.
* <p>
* @see SQLType
* @since 1.8
*/
public enum JDBCType implements SQLType {
/**
* Identifies the generic SQL type {@code BIT}.
*/
BIT(Types.BIT),
/**
* Identifies the generic SQL type {@code TINYINT}.
*/
TINYINT(Types.TINYINT),
/**
* Identifies the generic SQL type {@code SMALLINT}.
*/
SMALLINT(Types.SMALLINT),
/**
* Identifies the generic SQL type {@code INTEGER}.
*/
INTEGER(Types.INTEGER),
/**
* Identifies the generic SQL type {@code BIGINT}.
*/
BIGINT(Types.BIGINT),
/**
* Identifies the generic SQL type {@code FLOAT}.
*/
FLOAT(Types.FLOAT),
/**
* Identifies the generic SQL type {@code REAL}.
*/
REAL(Types.REAL),
/**
* Identifies the generic SQL type {@code DOUBLE}.
*/
DOUBLE(Types.DOUBLE),
/**
* Identifies the generic SQL type {@code NUMERIC}.
*/
NUMERIC(Types.NUMERIC),
/**
* Identifies the generic SQL type {@code DECIMAL}.
*/
DECIMAL(Types.DECIMAL),
/**
* Identifies the generic SQL type {@code CHAR}.
*/
CHAR(Types.CHAR),
/**
* Identifies the generic SQL type {@code VARCHAR}.
*/
VARCHAR(Types.VARCHAR),
/**
* Identifies the generic SQL type {@code LONGVARCHAR}.
*/
LONGVARCHAR(Types.LONGVARCHAR),
/**
* Identifies the generic SQL type {@code DATE}.
*/
DATE(Types.DATE),
/**
* Identifies the generic SQL type {@code TIME}.
*/
TIME(Types.TIME),
/**
* Identifies the generic SQL type {@code TIMESTAMP}.
*/
TIMESTAMP(Types.TIMESTAMP),
/**
* Identifies the generic SQL type {@code BINARY}.
*/
BINARY(Types.BINARY),
/**
* Identifies the generic SQL type {@code VARBINARY}.
*/
VARBINARY(Types.VARBINARY),
/**
* Identifies the generic SQL type {@code LONGVARBINARY}.
*/
LONGVARBINARY(Types.LONGVARBINARY),
/**
* Identifies the generic SQL value {@code NULL}.
*/
NULL(Types.NULL),
/**
* Indicates that the SQL type
* is database-specific and gets mapped to a Java object that can be
* accessed via the methods getObject and setObject.
*/
OTHER(Types.OTHER),
/**
* Indicates that the SQL type
* is database-specific and gets mapped to a Java object that can be
* accessed via the methods getObject and setObject.
*/
JAVA_OBJECT(Types.JAVA_OBJECT),
/**
* Identifies the generic SQL type {@code DISTINCT}.
*/
DISTINCT(Types.DISTINCT),
/**
* Identifies the generic SQL type {@code STRUCT}.
*/
STRUCT(Types.STRUCT),
/**
* Identifies the generic SQL type {@code ARRAY}.
*/
ARRAY(Types.ARRAY),
/**
* Identifies the generic SQL type {@code BLOB}.
*/
BLOB(Types.BLOB),
/**
* Identifies the generic SQL type {@code CLOB}.
*/
CLOB(Types.CLOB),
/**
* Identifies the generic SQL type {@code REF}.
*/
REF(Types.REF),
/**
* Identifies the generic SQL type {@code DATALINK}.
*/
DATALINK(Types.DATALINK),
/**
* Identifies the generic SQL type {@code BOOLEAN}.
*/
BOOLEAN(Types.BOOLEAN),
/* JDBC 4.0 Types */
/**
* Identifies the SQL type {@code ROWID}.
*/
ROWID(Types.ROWID),
/**
* Identifies the generic SQL type {@code NCHAR}.
*/
NCHAR(Types.NCHAR),
/**
* Identifies the generic SQL type {@code NVARCHAR}.
*/
NVARCHAR(Types.NVARCHAR),
/**
* Identifies the generic SQL type {@code LONGNVARCHAR}.
*/
LONGNVARCHAR(Types.LONGNVARCHAR),
/**
* Identifies the generic SQL type {@code NCLOB}.
*/
NCLOB(Types.NCLOB),
/**
* Identifies the generic SQL type {@code SQLXML}.
*/
SQLXML(Types.SQLXML),
/* JDBC 4.2 Types */
/**
* Identifies the generic SQL type {@code REF_CURSOR}.
*/
REF_CURSOR(Types.REF_CURSOR),
/**
* Identifies the generic SQL type {@code TIME_WITH_TIMEZONE}.
*/
TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE),
/**
* Identifies the generic SQL type {@code TIMESTAMP_WITH_TIMEZONE}.
*/
TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE);
/**
* The Integer value for the JDBCType. It maps to a value in
* {@code Types.java}
*/
private Integer type;
/**
* Constructor to specify the data type value from {@code Types) for
* this data type.
* @param type The value from {@code Types) for this data type
*/
JDBCType(final Integer type) {
this.type = type;
}
/**
*{@inheritDoc }
* @return The name of this {@code SQLType}.
*/
public String getName() {
return name();
}
/**
* Returns the name of the vendor that supports this data type.
* @return The name of the vendor for this data type which is
* {@literal java.sql} for JDBCType.
*/
public String getVendor() {
return "java.sql";
}
/**
* Returns the vendor specific type number for the data type.
* @return An Integer representing the data type. For {@code JDBCType},
* the value will be the same value as in {@code Types} for the data type.
*/
public Integer getVendorTypeNumber() {
return type;
}
/**
* Returns the {@code JDBCType} that corresponds to the specified
* {@code Types} value
* @param type {@code Types} value
* @return The {@code JDBCType} constant
* @throws IllegalArgumentException if this enum type has no constant with
* the specified {@code Types} value
* @see Types
*/
public static JDBCType valueOf(int type) {
for( JDBCType sqlType : JDBCType.class.getEnumConstants()) {
if(type == sqlType.type)
return sqlType;
}
throw new IllegalArgumentException("Type:" + type + " is not a valid "
+ "Types.java value.");
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.sql.Clob;
/**
* The mapping in the Java&trade; programming language
* for the SQL <code>NCLOB</code> type.
* An SQL <code>NCLOB</code> is a built-in type
* that stores a Character Large Object using the National Character Set
* as a column value in a row of a database table.
* <P>The <code>NClob</code> interface extends the <code>Clob</code> interface
* which provides provides methods for getting the
* length of an SQL <code>NCLOB</code> value,
* for materializing a <code>NCLOB</code> value on the client, and for
* searching for a substring or <code>NCLOB</code> object within a
* <code>NCLOB</code> value. A <code>NClob</code> object, just like a <code>Clob</code> object, is valid for the duration
* of the transaction in which it was created.
* Methods in the interfaces {@link ResultSet},
* {@link CallableStatement}, and {@link PreparedStatement}, such as
* <code>getNClob</code> and <code>setNClob</code> allow a programmer to
* access an SQL <code>NCLOB</code> value. In addition, this interface
* has methods for updating a <code>NCLOB</code> value.
* <p>
* All methods on the <code>NClob</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @since 1.6
*/
public interface NClob extends Clob { }

View File

@@ -0,0 +1,196 @@
/*
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An object that can be used to get information about the types
* and properties for each parameter marker in a
* <code>PreparedStatement</code> object. For some queries and driver
* implementations, the data that would be returned by a <code>ParameterMetaData</code>
* object may not be available until the <code>PreparedStatement</code> has
* been executed.
*<p>
*Some driver implementations may not be able to provide information about the
*types and properties for each parameter marker in a <code>CallableStatement</code>
*object.
*
* @since 1.4
*/
public interface ParameterMetaData extends Wrapper {
/**
* Retrieves the number of parameters in the <code>PreparedStatement</code>
* object for which this <code>ParameterMetaData</code> object contains
* information.
*
* @return the number of parameters
* @exception SQLException if a database access error occurs
* @since 1.4
*/
int getParameterCount() throws SQLException;
/**
* Retrieves whether null values are allowed in the designated parameter.
*
* @param param the first parameter is 1, the second is 2, ...
* @return the nullability status of the given parameter; one of
* <code>ParameterMetaData.parameterNoNulls</code>,
* <code>ParameterMetaData.parameterNullable</code>, or
* <code>ParameterMetaData.parameterNullableUnknown</code>
* @exception SQLException if a database access error occurs
* @since 1.4
*/
int isNullable(int param) throws SQLException;
/**
* The constant indicating that a
* parameter will not allow <code>NULL</code> values.
*/
int parameterNoNulls = 0;
/**
* The constant indicating that a
* parameter will allow <code>NULL</code> values.
*/
int parameterNullable = 1;
/**
* The constant indicating that the
* nullability of a parameter is unknown.
*/
int parameterNullableUnknown = 2;
/**
* Retrieves whether values for the designated parameter can be signed numbers.
*
* @param param the first parameter is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
* @since 1.4
*/
boolean isSigned(int param) throws SQLException;
/**
* Retrieves the designated parameter's specified column size.
*
* <P>The returned value represents the maximum column size for the given parameter.
* For numeric data, this is the maximum precision. For character data, this is the length in characters.
* For datetime datatypes, this is the length in characters of the String representation (assuming the
* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,
* this is the length in bytes. 0 is returned for data types where the
* column size is not applicable.
*
* @param param the first parameter is 1, the second is 2, ...
* @return precision
* @exception SQLException if a database access error occurs
* @since 1.4
*/
int getPrecision(int param) throws SQLException;
/**
* Retrieves the designated parameter's number of digits to right of the decimal point.
* 0 is returned for data types where the scale is not applicable.
*
* @param param the first parameter is 1, the second is 2, ...
* @return scale
* @exception SQLException if a database access error occurs
* @since 1.4
*/
int getScale(int param) throws SQLException;
/**
* Retrieves the designated parameter's SQL type.
*
* @param param the first parameter is 1, the second is 2, ...
* @return SQL type from <code>java.sql.Types</code>
* @exception SQLException if a database access error occurs
* @since 1.4
* @see Types
*/
int getParameterType(int param) throws SQLException;
/**
* Retrieves the designated parameter's database-specific type name.
*
* @param param the first parameter is 1, the second is 2, ...
* @return type the name used by the database. If the parameter type is
* a user-defined type, then a fully-qualified type name is returned.
* @exception SQLException if a database access error occurs
* @since 1.4
*/
String getParameterTypeName(int param) throws SQLException;
/**
* Retrieves the fully-qualified name of the Java class whose instances
* should be passed to the method <code>PreparedStatement.setObject</code>.
*
* @param param the first parameter is 1, the second is 2, ...
* @return the fully-qualified name of the class in the Java programming
* language that would be used by the method
* <code>PreparedStatement.setObject</code> to set the value
* in the specified parameter. This is the class name used
* for custom mapping.
* @exception SQLException if a database access error occurs
* @since 1.4
*/
String getParameterClassName(int param) throws SQLException;
/**
* The constant indicating that the mode of the parameter is unknown.
*/
int parameterModeUnknown = 0;
/**
* The constant indicating that the parameter's mode is IN.
*/
int parameterModeIn = 1;
/**
* The constant indicating that the parameter's mode is INOUT.
*/
int parameterModeInOut = 2;
/**
* The constant indicating that the parameter's mode is OUT.
*/
int parameterModeOut = 4;
/**
* Retrieves the designated parameter's mode.
*
* @param param the first parameter is 1, the second is 2, ...
* @return mode of the parameter; one of
* <code>ParameterMetaData.parameterModeIn</code>,
* <code>ParameterMetaData.parameterModeOut</code>, or
* <code>ParameterMetaData.parameterModeInOut</code>
* <code>ParameterMetaData.parameterModeUnknown</code>.
* @exception SQLException if a database access error occurs
* @since 1.4
*/
int getParameterMode(int param) throws SQLException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* Enumeration for pseudo/hidden column usage.
*
* @since 1.7
* @see DatabaseMetaData#getPseudoColumns
*/
public enum PseudoColumnUsage {
/**
* The pseudo/hidden column may only be used in a SELECT list.
*/
SELECT_LIST_ONLY,
/**
* The pseudo/hidden column may only be used in a WHERE clause.
*/
WHERE_CLAUSE_ONLY,
/**
* There are no restrictions on the usage of the pseudo/hidden columns.
*/
NO_USAGE_RESTRICTIONS,
/**
* The usage of the pseudo/hidden column cannot be determined.
*/
USAGE_UNKNOWN
}

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The mapping in the Java programming language of an SQL <code>REF</code>
* value, which is a reference to an SQL structured type value in the database.
* <P>
* SQL <code>REF</code> values are stored in a table that contains
* instances of a referenceable SQL structured type, and each <code>REF</code>
* value is a unique identifier for one instance in that table.
* An SQL <code>REF</code> value may be used in place of the
* SQL structured type it references, either as a column value in a
* table or an attribute value in a structured type.
* <P>
* Because an SQL <code>REF</code> value is a logical pointer to an
* SQL structured type, a <code>Ref</code> object is by default also a logical
* pointer. Thus, retrieving an SQL <code>REF</code> value as
* a <code>Ref</code> object does not materialize
* the attributes of the structured type on the client.
* <P>
* A <code>Ref</code> object can be stored in the database using the
* <code>PreparedStatement.setRef</code> method.
* <p>
* All methods on the <code>Ref</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @see Struct
* @since 1.2
*/
public interface Ref {
/**
* Retrieves the fully-qualified SQL name of the SQL structured type that
* this <code>Ref</code> object references.
*
* @return the fully-qualified SQL name of the referenced SQL structured type
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String getBaseTypeName() throws SQLException;
/**
* Retrieves the referenced object and maps it to a Java type
* using the given type map.
*
* @param map a <code>java.util.Map</code> object that contains
* the mapping to use (the fully-qualified name of the SQL
* structured type being referenced and the class object for
* <code>SQLData</code> implementation to which the SQL
* structured type will be mapped)
* @return a Java <code>Object</code> that is the custom mapping for
* the SQL structured type to which this <code>Ref</code>
* object refers
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
* @see #setObject
*/
Object getObject(java.util.Map<String,Class<?>> map) throws SQLException;
/**
* Retrieves the SQL structured type instance referenced by
* this <code>Ref</code> object. If the connection's type map has an entry
* for the structured type, the instance will be custom mapped to
* the Java class indicated in the type map. Otherwise, the
* structured type instance will be mapped to a <code>Struct</code> object.
*
* @return a Java <code>Object</code> that is the mapping for
* the SQL structured type to which this <code>Ref</code>
* object refers
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
* @see #setObject
*/
Object getObject() throws SQLException;
/**
* Sets the structured type value that this <code>Ref</code>
* object references to the given instance of <code>Object</code>.
* The driver converts this to an SQL structured type when it
* sends it to the database.
*
* @param value an <code>Object</code> representing the SQL
* structured type instance that this
* <code>Ref</code> object will reference
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
* @see #getObject()
* @see #getObject(Map)
* @see PreparedStatement#setObject(int, Object)
* @see CallableStatement#setObject(String, Object)
*/
void setObject(Object value) throws SQLException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
/*
* Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An object that can be used to get information about the types
* and properties of the columns in a <code>ResultSet</code> object.
* The following code fragment creates the <code>ResultSet</code> object rs,
* creates the <code>ResultSetMetaData</code> object rsmd, and uses rsmd
* to find out how many columns rs has and whether the first column in rs
* can be used in a <code>WHERE</code> clause.
* <PRE>
*
* ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM TABLE2");
* ResultSetMetaData rsmd = rs.getMetaData();
* int numberOfColumns = rsmd.getColumnCount();
* boolean b = rsmd.isSearchable(1);
*
* </PRE>
*/
public interface ResultSetMetaData extends Wrapper {
/**
* Returns the number of columns in this <code>ResultSet</code> object.
*
* @return the number of columns
* @exception SQLException if a database access error occurs
*/
int getColumnCount() throws SQLException;
/**
* Indicates whether the designated column is automatically numbered.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isAutoIncrement(int column) throws SQLException;
/**
* Indicates whether a column's case matters.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isCaseSensitive(int column) throws SQLException;
/**
* Indicates whether the designated column can be used in a where clause.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isSearchable(int column) throws SQLException;
/**
* Indicates whether the designated column is a cash value.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isCurrency(int column) throws SQLException;
/**
* Indicates the nullability of values in the designated column.
*
* @param column the first column is 1, the second is 2, ...
* @return the nullability status of the given column; one of <code>columnNoNulls</code>,
* <code>columnNullable</code> or <code>columnNullableUnknown</code>
* @exception SQLException if a database access error occurs
*/
int isNullable(int column) throws SQLException;
/**
* The constant indicating that a
* column does not allow <code>NULL</code> values.
*/
int columnNoNulls = 0;
/**
* The constant indicating that a
* column allows <code>NULL</code> values.
*/
int columnNullable = 1;
/**
* The constant indicating that the
* nullability of a column's values is unknown.
*/
int columnNullableUnknown = 2;
/**
* Indicates whether values in the designated column are signed numbers.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isSigned(int column) throws SQLException;
/**
* Indicates the designated column's normal maximum width in characters.
*
* @param column the first column is 1, the second is 2, ...
* @return the normal maximum number of characters allowed as the width
* of the designated column
* @exception SQLException if a database access error occurs
*/
int getColumnDisplaySize(int column) throws SQLException;
/**
* Gets the designated column's suggested title for use in printouts and
* displays. The suggested title is usually specified by the SQL <code>AS</code>
* clause. If a SQL <code>AS</code> is not specified, the value returned from
* <code>getColumnLabel</code> will be the same as the value returned by the
* <code>getColumnName</code> method.
*
* @param column the first column is 1, the second is 2, ...
* @return the suggested column title
* @exception SQLException if a database access error occurs
*/
String getColumnLabel(int column) throws SQLException;
/**
* Get the designated column's name.
*
* @param column the first column is 1, the second is 2, ...
* @return column name
* @exception SQLException if a database access error occurs
*/
String getColumnName(int column) throws SQLException;
/**
* Get the designated column's table's schema.
*
* @param column the first column is 1, the second is 2, ...
* @return schema name or "" if not applicable
* @exception SQLException if a database access error occurs
*/
String getSchemaName(int column) throws SQLException;
/**
* Get the designated column's specified column size.
* For numeric data, this is the maximum precision. For character data, this is the length in characters.
* For datetime datatypes, this is the length in characters of the String representation (assuming the
* maximum allowed precision of the fractional seconds component). For binary data, this is the length in bytes. For the ROWID datatype,
* this is the length in bytes. 0 is returned for data types where the
* column size is not applicable.
*
* @param column the first column is 1, the second is 2, ...
* @return precision
* @exception SQLException if a database access error occurs
*/
int getPrecision(int column) throws SQLException;
/**
* Gets the designated column's number of digits to right of the decimal point.
* 0 is returned for data types where the scale is not applicable.
*
* @param column the first column is 1, the second is 2, ...
* @return scale
* @exception SQLException if a database access error occurs
*/
int getScale(int column) throws SQLException;
/**
* Gets the designated column's table name.
*
* @param column the first column is 1, the second is 2, ...
* @return table name or "" if not applicable
* @exception SQLException if a database access error occurs
*/
String getTableName(int column) throws SQLException;
/**
* Gets the designated column's table's catalog name.
*
* @param column the first column is 1, the second is 2, ...
* @return the name of the catalog for the table in which the given column
* appears or "" if not applicable
* @exception SQLException if a database access error occurs
*/
String getCatalogName(int column) throws SQLException;
/**
* Retrieves the designated column's SQL type.
*
* @param column the first column is 1, the second is 2, ...
* @return SQL type from java.sql.Types
* @exception SQLException if a database access error occurs
* @see Types
*/
int getColumnType(int column) throws SQLException;
/**
* Retrieves the designated column's database-specific type name.
*
* @param column the first column is 1, the second is 2, ...
* @return type name used by the database. If the column type is
* a user-defined type, then a fully-qualified type name is returned.
* @exception SQLException if a database access error occurs
*/
String getColumnTypeName(int column) throws SQLException;
/**
* Indicates whether the designated column is definitely not writable.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isReadOnly(int column) throws SQLException;
/**
* Indicates whether it is possible for a write on the designated column to succeed.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isWritable(int column) throws SQLException;
/**
* Indicates whether a write on the designated column will definitely succeed.
*
* @param column the first column is 1, the second is 2, ...
* @return <code>true</code> if so; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*/
boolean isDefinitelyWritable(int column) throws SQLException;
//--------------------------JDBC 2.0-----------------------------------
/**
* <p>Returns the fully-qualified name of the Java class whose instances
* are manufactured if the method <code>ResultSet.getObject</code>
* is called to retrieve a value
* from the column. <code>ResultSet.getObject</code> may return a subclass of the
* class returned by this method.
*
* @param column the first column is 1, the second is 2, ...
* @return the fully-qualified name of the class in the Java programming
* language that would be used by the method
* <code>ResultSet.getObject</code> to retrieve the value in the specified
* column. This is the class name used for custom mapping.
* @exception SQLException if a database access error occurs
* @since 1.2
*/
String getColumnClassName(int column) throws SQLException;
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
*
* The representation (mapping) in the Java programming language of an SQL ROWID
* value. An SQL ROWID is a built-in type, a value of which can be thought of as
* an address for its identified row in a database table. Whether that address
* is logical or, in any respects, physical is determined by its originating data
* source.
* <p>
* Methods in the interfaces <code>ResultSet</code>, <code>CallableStatement</code>,
* and <code>PreparedStatement</code>, such as <code>getRowId</code> and <code>setRowId</code>
* allow a programmer to access a SQL <code>ROWID</code> value. The <code>RowId</code>
* interface provides a method
* for representing the value of the <code>ROWID</code> as a byte array or as a
* <code>String</code>.
* <p>
* The method <code>getRowIdLifetime</code> in the interface <code>DatabaseMetaData</code>,
* can be used
* to determine if a <code>RowId</code> object remains valid for the duration of the transaction in
* which the <code>RowId</code> was created, the duration of the session in which
* the <code>RowId</code> was created,
* or, effectively, for as long as its identified row is not deleted. In addition
* to specifying the duration of its valid lifetime outside its originating data
* source, <code>getRowIdLifetime</code> specifies the duration of a <code>ROWID</code>
* value's valid lifetime
* within its originating data source. In this, it differs from a large object,
* because there is no limit on the valid lifetime of a large object within its
* originating data source.
* <p>
* All methods on the <code>RowId</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @see java.sql.DatabaseMetaData
* @since 1.6
*/
public interface RowId {
/**
* Compares this <code>RowId</code> to the specified object. The result is
* <code>true</code> if and only if the argument is not null and is a RowId
* object that represents the same ROWID as this object.
* <p>
* It is important
* to consider both the origin and the valid lifetime of a <code>RowId</code>
* when comparing it to another <code>RowId</code>. If both are valid, and
* both are from the same table on the same data source, then if they are equal
* they identify
* the same row; if one or more is no longer guaranteed to be valid, or if
* they originate from different data sources, or different tables on the
* same data source, they may be equal but still
* not identify the same row.
*
* @param obj the <code>Object</code> to compare this <code>RowId</code> object
* against.
* @return true if the <code>RowId</code>s are equal; false otherwise
* @since 1.6
*/
boolean equals(Object obj);
/**
* Returns an array of bytes representing the value of the SQL <code>ROWID</code>
* designated by this <code>java.sql.RowId</code> object.
*
* @return an array of bytes, whose length is determined by the driver supplying
* the connection, representing the value of the ROWID designated by this
* java.sql.RowId object.
*/
byte[] getBytes();
/**
* Returns a String representing the value of the SQL ROWID designated by this
* <code>java.sql.RowId</code> object.
* <p>
*Like <code>java.sql.Date.toString()</code>
* returns the contents of its DATE as the <code>String</code> "2004-03-17"
* rather than as DATE literal in SQL (which would have been the <code>String</code>
* DATE "2004-03-17"), toString()
* returns the contents of its ROWID in a form specific to the driver supplying
* the connection, and possibly not as a <code>ROWID</code> literal.
*
* @return a String whose format is determined by the driver supplying the
* connection, representing the value of the <code>ROWID</code> designated
* by this <code>java.sql.RowId</code> object.
*/
String toString();
/**
* Returns a hash code value of this <code>RowId</code> object.
*
* @return a hash code for the <code>RowId</code>
*/
int hashCode();
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.*;
/**
* Enumeration for RowId life-time values.
*
* @since 1.6
*/
public enum RowIdLifetime {
/**
* Indicates that this data source does not support the ROWID type.
*/
ROWID_UNSUPPORTED,
/**
* Indicates that the lifetime of a RowId from this data source is indeterminate;
* but not one of ROWID_VALID_TRANSACTION, ROWID_VALID_SESSION, or,
* ROWID_VALID_FOREVER.
*/
ROWID_VALID_OTHER,
/**
* Indicates that the lifetime of a RowId from this data source is at least the
* containing session.
*/
ROWID_VALID_SESSION,
/**
* Indicates that the lifetime of a RowId from this data source is at least the
* containing transaction.
*/
ROWID_VALID_TRANSACTION,
/**
* Indicates that the lifetime of a RowId from this data source is, effectively,
* unlimited.
*/
ROWID_VALID_FOREVER
}

View File

@@ -0,0 +1,321 @@
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.Map;
/**
* The subclass of {@link SQLException} is thrown when one or more client info properties
* could not be set on a <code>Connection</code>. In addition to the information provided
* by <code>SQLException</code>, a <code>SQLClientInfoException</code> provides a list of client info
* properties that were not set.
*
* Some databases do not allow multiple client info properties to be set
* atomically. For those databases, it is possible that some of the client
* info properties had been set even though the <code>Connection.setClientInfo</code>
* method threw an exception. An application can use the <code>getFailedProperties </code>
* method to retrieve a list of client info properties that were not set. The
* properties are identified by passing a
* <code>Map&lt;String,ClientInfoStatus&gt;</code> to
* the appropriate <code>SQLClientInfoException</code> constructor.
* <p>
* @see ClientInfoStatus
* @see Connection#setClientInfo
* @since 1.6
*/
public class SQLClientInfoException extends SQLException {
private Map<String, ClientInfoStatus> failedProperties;
/**
* Constructs a <code>SQLClientInfoException</code> Object.
* The <code>reason</code>,
* <code>SQLState</code>, and failedProperties list are initialized to
* <code> null</code> and the vendor code is initialized to 0.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @since 1.6
*/
public SQLClientInfoException() {
this.failedProperties = null;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>failedProperties</code>.
* The <code>reason</code> and <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* <p>
* @since 1.6
*/
public SQLClientInfoException(Map<String, ClientInfoStatus> failedProperties) {
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with
* a given <code>cause</code> and <code>failedProperties</code>.
*
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code> and the vendor code is initialized to 0.
*
* <p>
*
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* <p>
* @since 1.6
*/
public SQLClientInfoException(Map<String, ClientInfoStatus> failedProperties,
Throwable cause) {
super(cause != null?cause.toString():null);
initCause(cause);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code> and <code>failedProperties</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param reason a description of the exception
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
Map<String, ClientInfoStatus> failedProperties) {
super(reason);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code>, <code>cause</code> and
* <code>failedProperties</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* <p>
*
* @param reason a description of the exception
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
Map<String, ClientInfoStatus> failedProperties,
Throwable cause) {
super(reason);
initCause(cause);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code>, <code>SQLState</code> and
* <code>failedProperties</code>.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
*
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
String SQLState,
Map<String, ClientInfoStatus> failedProperties) {
super(reason, SQLState);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code>, <code>SQLState</code>, <code>cause</code>
* and <code>failedProperties</code>. The vendor code is initialized to 0.
* <p>
*
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
String SQLState,
Map<String, ClientInfoStatus> failedProperties,
Throwable cause) {
super(reason, SQLState);
initCause(cause);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code>, <code>SQLState</code>,
* <code>vendorCode</code> and <code>failedProperties</code>.
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
String SQLState,
int vendorCode,
Map<String, ClientInfoStatus> failedProperties) {
super(reason, SQLState, vendorCode);
this.failedProperties = failedProperties;
}
/**
* Constructs a <code>SQLClientInfoException</code> object initialized with a
* given <code>reason</code>, <code>SQLState</code>,
* <code>cause</code>, <code>vendorCode</code> and
* <code>failedProperties</code>.
* <p>
*
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param failedProperties A Map containing the property values that could not
* be set. The keys in the Map
* contain the names of the client info
* properties that could not be set and
* the values contain one of the reason codes
* defined in <code>ClientInfoStatus</code>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* <p>
* @since 1.6
*/
public SQLClientInfoException(String reason,
String SQLState,
int vendorCode,
Map<String, ClientInfoStatus> failedProperties,
Throwable cause) {
super(reason, SQLState, vendorCode);
initCause(cause);
this.failedProperties = failedProperties;
}
/**
* Returns the list of client info properties that could not be set. The
* keys in the Map contain the names of the client info
* properties that could not be set and the values contain one of the
* reason codes defined in <code>ClientInfoStatus</code>
* <p>
*
* @return Map list containing the client info properties that could
* not be set
* <p>
* @since 1.6
*/
public Map<String, ClientInfoStatus> getFailedProperties() {
return this.failedProperties;
}
private static final long serialVersionUID = -4319604256824655880L;
}

View File

@@ -0,0 +1,137 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The interface used for the custom mapping of an SQL user-defined type (UDT) to
* a class in the Java programming language. The class object for a class
* implementing the <code>SQLData</code> interface will be entered in the
* appropriate <code>Connection</code> object's type map along with the SQL
* name of the UDT for which it is a custom mapping.
* <P>
* Typically, a <code>SQLData</code> implementation
* will define a field for each attribute of an SQL structured type or a
* single field for an SQL <code>DISTINCT</code> type. When the UDT is
* retrieved from a data source with the <code>ResultSet.getObject</code>
* method, it will be mapped as an instance of this class. A programmer
* can operate on this class instance just as on any other object in the
* Java programming language and then store any changes made to it by
* calling the <code>PreparedStatement.setObject</code> method,
* which will map it back to the SQL type.
* <p>
* It is expected that the implementation of the class for a custom
* mapping will be done by a tool. In a typical implementation, the
* programmer would simply supply the name of the SQL UDT, the name of
* the class to which it is being mapped, and the names of the fields to
* which each of the attributes of the UDT is to be mapped. The tool will use
* this information to implement the <code>SQLData.readSQL</code> and
* <code>SQLData.writeSQL</code> methods. The <code>readSQL</code> method
* calls the appropriate <code>SQLInput</code> methods to read
* each attribute from an <code>SQLInput</code> object, and the
* <code>writeSQL</code> method calls <code>SQLOutput</code> methods
* to write each attribute back to the data source via an
* <code>SQLOutput</code> object.
* <P>
* An application programmer will not normally call <code>SQLData</code> methods
* directly, and the <code>SQLInput</code> and <code>SQLOutput</code> methods
* are called internally by <code>SQLData</code> methods, not by application code.
*
* @since 1.2
*/
public interface SQLData {
/**
* Returns the fully-qualified
* name of the SQL user-defined type that this object represents.
* This method is called by the JDBC driver to get the name of the
* UDT instance that is being mapped to this instance of
* <code>SQLData</code>.
*
* @return the type name that was passed to the method <code>readSQL</code>
* when this object was constructed and populated
* @exception SQLException if there is a database access error
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String getSQLTypeName() throws SQLException;
/**
* Populates this object with data read from the database.
* The implementation of the method must follow this protocol:
* <UL>
* <LI>It must read each of the attributes or elements of the SQL
* type from the given input stream. This is done
* by calling a method of the input stream to read each
* item, in the order that they appear in the SQL definition
* of the type.
* <LI>The method <code>readSQL</code> then
* assigns the data to appropriate fields or
* elements (of this or other objects).
* Specifically, it must call the appropriate <i>reader</i> method
* (<code>SQLInput.readString</code>, <code>SQLInput.readBigDecimal</code>,
* and so on) method(s) to do the following:
* for a distinct type, read its single data element;
* for a structured type, read a value for each attribute of the SQL type.
* </UL>
* The JDBC driver initializes the input stream with a type map
* before calling this method, which is used by the appropriate
* <code>SQLInput</code> reader method on the stream.
*
* @param stream the <code>SQLInput</code> object from which to read the data for
* the value that is being custom mapped
* @param typeName the SQL type name of the value on the data stream
* @exception SQLException if there is a database access error
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see SQLInput
* @since 1.2
*/
void readSQL (SQLInput stream, String typeName) throws SQLException;
/**
* Writes this object to the given SQL data stream, converting it back to
* its SQL value in the data source.
* The implementation of the method must follow this protocol:<BR>
* It must write each of the attributes of the SQL type
* to the given output stream. This is done by calling a
* method of the output stream to write each item, in the order that
* they appear in the SQL definition of the type.
* Specifically, it must call the appropriate <code>SQLOutput</code> writer
* method(s) (<code>writeInt</code>, <code>writeString</code>, and so on)
* to do the following: for a Distinct Type, write its single data element;
* for a Structured Type, write a value for each attribute of the SQL type.
*
* @param stream the <code>SQLOutput</code> object to which to write the data for
* the value that was custom mapped
* @exception SQLException if there is a database access error
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @see SQLOutput
* @since 1.2
*/
void writeSQL (SQLOutput stream) throws SQLException;
}

View File

@@ -0,0 +1,173 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value
* is '<i>22</i>', or under vendor-specified conditions. This indicates
* various data errors, including but not limited to data conversion errors,
* division by 0, and invalid arguments to functions.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLDataException extends SQLNonTransientException {
/**
* Constructs a <code>SQLDataException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @since 1.6
*/
public SQLDataException() {
super();
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param reason a description of the exception
* @since 1.6
*/
public SQLDataException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code> and <code>SQLState</code>. The
* vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLDataException(String reason, String SQLState) {
super(reason, SQLState);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLDataException(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLDataException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLDataException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLDataException(String reason, String SQLState, Throwable cause) {
super(reason, SQLState, cause);
}
/**
* Constructs a <code>SQLDataException</code> object with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLDataException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason, SQLState, vendorCode, cause);
}
private static final long serialVersionUID = -6889123282670549800L;
}

View File

@@ -0,0 +1,375 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
/**
* <P>An exception that provides information on a database access
* error or other errors.
*
* <P>Each <code>SQLException</code> provides several kinds of information:
* <UL>
* <LI> a string describing the error. This is used as the Java Exception
* message, available via the method <code>getMesasge</code>.
* <LI> a "SQLstate" string, which follows either the XOPEN SQLstate conventions
* or the SQL:2003 conventions.
* The values of the SQLState string are described in the appropriate spec.
* The <code>DatabaseMetaData</code> method <code>getSQLStateType</code>
* can be used to discover whether the driver returns the XOPEN type or
* the SQL:2003 type.
* <LI> an integer error code that is specific to each vendor. Normally this will
* be the actual error code returned by the underlying database.
* <LI> a chain to a next Exception. This can be used to provide additional
* error information.
* <LI> the causal relationship, if any for this <code>SQLException</code>.
* </UL>
*/
public class SQLException extends java.lang.Exception
implements Iterable<Throwable> {
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
*/
public SQLException(String reason, String SQLState, int vendorCode) {
super(reason);
this.SQLState = SQLState;
this.vendorCode = vendorCode;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
DriverManager.println("SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
*/
public SQLException(String reason, String SQLState) {
super(reason);
this.SQLState = SQLState;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
DriverManager.println("SQLException: SQLState(" + SQLState + ")");
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code>. The <code>SQLState</code> is initialized to
* <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
*/
public SQLException(String reason) {
super(reason);
this.SQLState = null;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Constructs a <code>SQLException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
*
*/
public SQLException() {
super();
this.SQLState = null;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
* @since 1.6
*/
public SQLException(Throwable cause) {
super(cause);
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
* @since 1.6
*/
public SQLException(String reason, Throwable cause) {
super(reason,cause);
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param sqlState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the
* <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLException(String reason, String sqlState, Throwable cause) {
super(reason,cause);
this.SQLState = sqlState;
this.vendorCode = 0;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
printStackTrace(DriverManager.getLogWriter());
DriverManager.println("SQLState(" + SQLState + ")");
}
}
}
/**
* Constructs a <code>SQLException</code> object with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param sqlState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
* @since 1.6
*/
public SQLException(String reason, String sqlState, int vendorCode, Throwable cause) {
super(reason,cause);
this.SQLState = sqlState;
this.vendorCode = vendorCode;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
DriverManager.println("SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
printStackTrace(DriverManager.getLogWriter());
}
}
}
/**
* Retrieves the SQLState for this <code>SQLException</code> object.
*
* @return the SQLState value
*/
public String getSQLState() {
return (SQLState);
}
/**
* Retrieves the vendor-specific exception code
* for this <code>SQLException</code> object.
*
* @return the vendor's error code
*/
public int getErrorCode() {
return (vendorCode);
}
/**
* Retrieves the exception chained to this
* <code>SQLException</code> object by setNextException(SQLException ex).
*
* @return the next <code>SQLException</code> object in the chain;
* <code>null</code> if there are none
* @see #setNextException
*/
public SQLException getNextException() {
return (next);
}
/**
* Adds an <code>SQLException</code> object to the end of the chain.
*
* @param ex the new exception that will be added to the end of
* the <code>SQLException</code> chain
* @see #getNextException
*/
public void setNextException(SQLException ex) {
SQLException current = this;
for(;;) {
SQLException next=current.next;
if (next != null) {
current = next;
continue;
}
if (nextUpdater.compareAndSet(current,null,ex)) {
return;
}
current=current.next;
}
}
/**
* Returns an iterator over the chained SQLExceptions. The iterator will
* be used to iterate over each SQLException and its underlying cause
* (if any).
*
* @return an iterator over the chained SQLExceptions and causes in the proper
* order
*
* @since 1.6
*/
public Iterator<Throwable> iterator() {
return new Iterator<Throwable>() {
SQLException firstException = SQLException.this;
SQLException nextException = firstException.getNextException();
Throwable cause = firstException.getCause();
public boolean hasNext() {
if(firstException != null || nextException != null || cause != null)
return true;
return false;
}
public Throwable next() {
Throwable throwable = null;
if(firstException != null){
throwable = firstException;
firstException = null;
}
else if(cause != null){
throwable = cause;
cause = cause.getCause();
}
else if(nextException != null){
throwable = nextException;
cause = nextException.getCause();
nextException = nextException.getNextException();
}
else
throw new NoSuchElementException();
return throwable;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
/**
* @serial
*/
private String SQLState;
/**
* @serial
*/
private int vendorCode;
/**
* @serial
*/
private volatile SQLException next;
private static final AtomicReferenceFieldUpdater<SQLException,SQLException> nextUpdater =
AtomicReferenceFieldUpdater.newUpdater(SQLException.class,SQLException.class,"next");
private static final long serialVersionUID = 2135244094396331484L;
}

View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value is '<i>0A</i>'
* ( the value is 'zero' A).
* This indicates that the JDBC driver does not support an optional JDBC feature.
* Optional JDBC features can fall into the fallowing categories:
*
*<UL>
*<LI>no support for an optional feature
*<LI>no support for an optional overloaded method
*<LI>no support for an optional mode for a method. The mode for a method is
*determined based on constants passed as parameter values to a method
*</UL>
*
* @since 1.6
*/
public class SQLFeatureNotSupportedException extends SQLNonTransientException {
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLFeatureNotSupportedException() {
super();
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLFeatureNotSupportedException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLFeatureNotSupportedException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLFeatureNotSupportedException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -1026510870282316051L;
}

View File

@@ -0,0 +1,459 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An input stream that contains a stream of values representing an
* instance of an SQL structured type or an SQL distinct type.
* This interface, used only for custom mapping, is used by the driver
* behind the scenes, and a programmer never directly invokes
* <code>SQLInput</code> methods. The <i>reader</i> methods
* (<code>readLong</code>, <code>readBytes</code>, and so on)
* provide a way for an implementation of the <code>SQLData</code>
* interface to read the values in an <code>SQLInput</code> object.
* And as described in <code>SQLData</code>, calls to reader methods must
* be made in the order that their corresponding attributes appear in the
* SQL definition of the type.
* The method <code>wasNull</code> is used to determine whether
* the last value read was SQL <code>NULL</code>.
* <P>When the method <code>getObject</code> is called with an
* object of a class implementing the interface <code>SQLData</code>,
* the JDBC driver calls the method <code>SQLData.getSQLType</code>
* to determine the SQL type of the user-defined type (UDT)
* being custom mapped. The driver
* creates an instance of <code>SQLInput</code>, populating it with the
* attributes of the UDT. The driver then passes the input
* stream to the method <code>SQLData.readSQL</code>, which in turn
* calls the <code>SQLInput</code> reader methods
* in its implementation for reading the
* attributes from the input stream.
* @since 1.2
*/
public interface SQLInput {
//================================================================
// Methods for reading attributes from the stream of SQL data.
// These methods correspond to the column-accessor methods of
// java.sql.ResultSet.
//================================================================
/**
* Reads the next attribute in the stream and returns it as a <code>String</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String readString() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>boolean</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>false</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
boolean readBoolean() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>byte</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
byte readByte() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>short</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
short readShort() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as an <code>int</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
int readInt() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>long</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
long readLong() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>float</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
float readFloat() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>double</code>
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>0</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
double readDouble() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>java.math.BigDecimal</code>
* object in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.math.BigDecimal readBigDecimal() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as an array of bytes
* in the Java programming language.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
byte[] readBytes() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>java.sql.Date</code> object.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.sql.Date readDate() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>java.sql.Time</code> object.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.sql.Time readTime() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>java.sql.Timestamp</code> object.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.sql.Timestamp readTimestamp() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a stream of Unicode characters.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.io.Reader readCharacterStream() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a stream of ASCII characters.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.io.InputStream readAsciiStream() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a stream of uninterpreted
* bytes.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
java.io.InputStream readBinaryStream() throws SQLException;
//================================================================
// Methods for reading items of SQL user-defined types from the stream.
//================================================================
/**
* Reads the datum at the head of the stream and returns it as an
* <code>Object</code> in the Java programming language. The
* actual type of the object returned is determined by the default type
* mapping, and any customizations present in this stream's type map.
*
* <P>A type map is registered with the stream by the JDBC driver before the
* stream is passed to the application.
*
* <P>When the datum at the head of the stream is an SQL <code>NULL</code>,
* the method returns <code>null</code>. If the datum is an SQL structured or distinct
* type, it determines the SQL type of the datum at the head of the stream.
* If the stream's type map has an entry for that SQL type, the driver
* constructs an object of the appropriate class and calls the method
* <code>SQLData.readSQL</code> on that object, which reads additional data from the
* stream, using the protocol described for that method.
*
* @return the datum at the head of the stream as an <code>Object</code> in the
* Java programming language;<code>null</code> if the datum is SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object readObject() throws SQLException;
/**
* Reads an SQL <code>REF</code> value from the stream and returns it as a
* <code>Ref</code> object in the Java programming language.
*
* @return a <code>Ref</code> object representing the SQL <code>REF</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Ref readRef() throws SQLException;
/**
* Reads an SQL <code>BLOB</code> value from the stream and returns it as a
* <code>Blob</code> object in the Java programming language.
*
* @return a <code>Blob</code> object representing data of the SQL <code>BLOB</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Blob readBlob() throws SQLException;
/**
* Reads an SQL <code>CLOB</code> value from the stream and returns it as a
* <code>Clob</code> object in the Java programming language.
*
* @return a <code>Clob</code> object representing data of the SQL <code>CLOB</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Clob readClob() throws SQLException;
/**
* Reads an SQL <code>ARRAY</code> value from the stream and returns it as an
* <code>Array</code> object in the Java programming language.
*
* @return an <code>Array</code> object representing data of the SQL
* <code>ARRAY</code> value at the head of the stream; <code>null</code>
* if the value read is SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Array readArray() throws SQLException;
/**
* Retrieves whether the last value read was SQL <code>NULL</code>.
*
* @return <code>true</code> if the most recently read SQL value was SQL
* <code>NULL</code>; <code>false</code> otherwise
* @exception SQLException if a database access error occurs
*
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
boolean wasNull() throws SQLException;
//---------------------------- JDBC 3.0 -------------------------
/**
* Reads an SQL <code>DATALINK</code> value from the stream and returns it as a
* <code>java.net.URL</code> object in the Java programming language.
*
* @return a <code>java.net.URL</code> object.
* @exception SQLException if a database access error occurs,
* or if a URL is malformed
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
java.net.URL readURL() throws SQLException;
//---------------------------- JDBC 4.0 -------------------------
/**
* Reads an SQL <code>NCLOB</code> value from the stream and returns it as a
* <code>NClob</code> object in the Java programming language.
*
* @return a <code>NClob</code> object representing data of the SQL <code>NCLOB</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
NClob readNClob() throws SQLException;
/**
* Reads the next attribute in the stream and returns it as a <code>String</code>
* in the Java programming language. It is intended for use when
* accessing <code>NCHAR</code>,<code>NVARCHAR</code>
* and <code>LONGNVARCHAR</code> columns.
*
* @return the attribute; if the value is SQL <code>NULL</code>, returns <code>null</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
String readNString() throws SQLException;
/**
* Reads an SQL <code>XML</code> value from the stream and returns it as a
* <code>SQLXML</code> object in the Java programming language.
*
* @return a <code>SQLXML</code> object representing data of the SQL <code>XML</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
SQLXML readSQLXML() throws SQLException;
/**
* Reads an SQL <code>ROWID</code> value from the stream and returns it as a
* <code>RowId</code> object in the Java programming language.
*
* @return a <code>RowId</code> object representing data of the SQL <code>ROWID</code> value
* at the head of the stream; <code>null</code> if the value read is
* SQL <code>NULL</code>
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
RowId readRowId() throws SQLException;
//--------------------------JDBC 4.2 -----------------------------
/**
* Reads the next attribute in the stream and returns it as an
* {@code Object} in the Java programming language. The
* actual type of the object returned is determined by the specified
* Java data type, and any customizations present in this
* stream's type map.
*
* <P>A type map is registered with the stream by the JDBC driver before the
* stream is passed to the application.
*
* <P>When the attribute at the head of the stream is an SQL {@code NULL}
* the method returns {@code null}. If the attribute is an SQL
* structured or distinct
* type, it determines the SQL type of the attribute at the head of the stream.
* If the stream's type map has an entry for that SQL type, the driver
* constructs an object of the appropriate class and calls the method
* {@code SQLData.readSQL} on that object, which reads additional data from the
* stream, using the protocol described for that method.
*<p>
* The default implementation will throw {@code SQLFeatureNotSupportedException}
*
* @param <T> the type of the class modeled by this Class object
* @param type Class representing the Java data type to convert the attribute to.
* @return the attribute at the head of the stream as an {@code Object} in the
* Java programming language;{@code null} if the attribute is SQL {@code NULL}
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.8
*/
default <T> T readObject(Class<T> type) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
}

View File

@@ -0,0 +1,174 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value
* is '<i>23</i>', or under vendor-specified conditions.
* This indicates that an integrity
* constraint (foreign key, primary key or unique key) has been violated.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLIntegrityConstraintViolationException extends SQLNonTransientException {
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLIntegrityConstraintViolationException() {
super();
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code>
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code>
* object with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs an <code>SQLIntegrityConstraintViolationException</code> object with
* a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState, cause);
}
/**
* Constructs a <code>SQLIntegrityConstraintViolationException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = 8033405298774849169L;
}

View File

@@ -0,0 +1,174 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value
* is '<i>28</i>', or under vendor-specified conditions. This indicates that
* the authorization credentials presented during connection establishment
* are not valid.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLInvalidAuthorizationSpecException extends SQLNonTransientException {
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException() {
super();
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLInvalidAuthorizationSpecException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLInvalidAuthorizationSpecException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -64105250450891498L;
}

View File

@@ -0,0 +1,176 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown for the SQLState
* class value '<i>08</i>', or under vendor-specified conditions. This
* indicates that the connection operation that failed will not succeed if
* the operation is retried without the cause of the failure being corrected.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLNonTransientConnectionException extends java.sql.SQLNonTransientException {
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @since 1.6
*/
public SQLNonTransientConnectionException() {
super();
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientConnectionException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLNonTransientConnectionException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientConnectionException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -5852318857474782892L;
}

View File

@@ -0,0 +1,175 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when an instance where a retry
* of the same operation would fail unless the cause of the <code>SQLException</code>
* is corrected.
*<p>
*
* @since 1.6
*/
public class SQLNonTransientException extends java.sql.SQLException {
/**
* Constructs a <code>SQLNonTransientException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @since 1.6
*/
public SQLNonTransientException() {
super();
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
*
* @param reason a description of the exception
* @since 1.6
*/
public SQLNonTransientException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLNonTransientException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLNonTransientException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLNonTransientException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLNonTransientException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -9104382843534716547L;
}

View File

@@ -0,0 +1,475 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The output stream for writing the attributes of a user-defined
* type back to the database. This interface, used
* only for custom mapping, is used by the driver, and its
* methods are never directly invoked by a programmer.
* <p>When an object of a class implementing the interface
* <code>SQLData</code> is passed as an argument to an SQL statement, the
* JDBC driver calls the method <code>SQLData.getSQLType</code> to
* determine the kind of SQL
* datum being passed to the database.
* The driver then creates an instance of <code>SQLOutput</code> and
* passes it to the method <code>SQLData.writeSQL</code>.
* The method <code>writeSQL</code> in turn calls the
* appropriate <code>SQLOutput</code> <i>writer</i> methods
* <code>writeBoolean</code>, <code>writeCharacterStream</code>, and so on)
* to write data from the <code>SQLData</code> object to
* the <code>SQLOutput</code> output stream as the
* representation of an SQL user-defined type.
* @since 1.2
*/
public interface SQLOutput {
//================================================================
// Methods for writing attributes to the stream of SQL data.
// These methods correspond to the column-accessor methods of
// java.sql.ResultSet.
//================================================================
/**
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeString(String x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java boolean.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeBoolean(boolean x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java byte.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeByte(byte x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java short.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeShort(short x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java int.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeInt(int x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java long.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeLong(long x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java float.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeFloat(float x) throws SQLException;
/**
* Writes the next attribute to the stream as a Java double.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeDouble(double x) throws SQLException;
/**
* Writes the next attribute to the stream as a java.math.BigDecimal object.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeBigDecimal(java.math.BigDecimal x) throws SQLException;
/**
* Writes the next attribute to the stream as an array of bytes.
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeBytes(byte[] x) throws SQLException;
/**
* Writes the next attribute to the stream as a java.sql.Date object.
* Writes the next attribute to the stream as a <code>java.sql.Date</code> object
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeDate(java.sql.Date x) throws SQLException;
/**
* Writes the next attribute to the stream as a java.sql.Time object.
* Writes the next attribute to the stream as a <code>java.sql.Date</code> object
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeTime(java.sql.Time x) throws SQLException;
/**
* Writes the next attribute to the stream as a java.sql.Timestamp object.
* Writes the next attribute to the stream as a <code>java.sql.Date</code> object
* in the Java programming language.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeTimestamp(java.sql.Timestamp x) throws SQLException;
/**
* Writes the next attribute to the stream as a stream of Unicode characters.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeCharacterStream(java.io.Reader x) throws SQLException;
/**
* Writes the next attribute to the stream as a stream of ASCII characters.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeAsciiStream(java.io.InputStream x) throws SQLException;
/**
* Writes the next attribute to the stream as a stream of uninterpreted
* bytes.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeBinaryStream(java.io.InputStream x) throws SQLException;
//================================================================
// Methods for writing items of SQL user-defined types to the stream.
// These methods pass objects to the database as values of SQL
// Structured Types, Distinct Types, Constructed Types, and Locator
// Types. They decompose the Java object(s) and write leaf data
// items using the methods above.
//================================================================
/**
* Writes to the stream the data contained in the given
* <code>SQLData</code> object.
* When the <code>SQLData</code> object is <code>null</code>, this
* method writes an SQL <code>NULL</code> to the stream.
* Otherwise, it calls the <code>SQLData.writeSQL</code>
* method of the given object, which
* writes the object's attributes to the stream.
* The implementation of the method <code>SQLData.writeSQL</code>
* calls the appropriate <code>SQLOutput</code> writer method(s)
* for writing each of the object's attributes in order.
* The attributes must be read from an <code>SQLInput</code>
* input stream and written to an <code>SQLOutput</code>
* output stream in the same order in which they were
* listed in the SQL definition of the user-defined type.
*
* @param x the object representing data of an SQL structured or
* distinct type
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeObject(SQLData x) throws SQLException;
/**
* Writes an SQL <code>REF</code> value to the stream.
*
* @param x a <code>Ref</code> object representing data of an SQL
* <code>REF</code> value
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeRef(Ref x) throws SQLException;
/**
* Writes an SQL <code>BLOB</code> value to the stream.
*
* @param x a <code>Blob</code> object representing data of an SQL
* <code>BLOB</code> value
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeBlob(Blob x) throws SQLException;
/**
* Writes an SQL <code>CLOB</code> value to the stream.
*
* @param x a <code>Clob</code> object representing data of an SQL
* <code>CLOB</code> value
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeClob(Clob x) throws SQLException;
/**
* Writes an SQL structured type value to the stream.
*
* @param x a <code>Struct</code> object representing data of an SQL
* structured type
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeStruct(Struct x) throws SQLException;
/**
* Writes an SQL <code>ARRAY</code> value to the stream.
*
* @param x an <code>Array</code> object representing data of an SQL
* <code>ARRAY</code> type
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
void writeArray(Array x) throws SQLException;
//--------------------------- JDBC 3.0 ------------------------
/**
* Writes a SQL <code>DATALINK</code> value to the stream.
*
* @param x a <code>java.net.URL</code> object representing the data
* of SQL DATALINK type
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void writeURL(java.net.URL x) throws SQLException;
//--------------------------- JDBC 4.0 ------------------------
/**
* Writes the next attribute to the stream as a <code>String</code>
* in the Java programming language. The driver converts this to a
* SQL <code>NCHAR</code> or
* <code>NVARCHAR</code> or <code>LONGNVARCHAR</code> value
* (depending on the argument's
* size relative to the driver's limits on <code>NVARCHAR</code> values)
* when it sends it to the stream.
*
* @param x the value to pass to the database
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void writeNString(String x) throws SQLException;
/**
* Writes an SQL <code>NCLOB</code> value to the stream.
*
* @param x a <code>NClob</code> object representing data of an SQL
* <code>NCLOB</code> value
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void writeNClob(NClob x) throws SQLException;
/**
* Writes an SQL <code>ROWID</code> value to the stream.
*
* @param x a <code>RowId</code> object representing data of an SQL
* <code>ROWID</code> value
*
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void writeRowId(RowId x) throws SQLException;
/**
* Writes an SQL <code>XML</code> value to the stream.
*
* @param x a <code>SQLXML</code> object representing data of an SQL
* <code>XML</code> value
*
* @throws SQLException if a database access error occurs,
* the <code>java.xml.transform.Result</code>,
* <code>Writer</code> or <code>OutputStream</code> has not been closed for the <code>SQLXML</code> object or
* if there is an error processing the XML value. The <code>getCause</code> method
* of the exception may provide a more detailed exception, for example, if the
* stream does not contain valid XML.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void writeSQLXML(SQLXML x) throws SQLException;
//--------------------------JDBC 4.2 -----------------------------
/**
* Writes to the stream the data contained in the given object. The
* object will be converted to the specified targetSqlType
* before being sent to the stream.
*<p>
* When the {@code object} is {@code null}, this
* method writes an SQL {@code NULL} to the stream.
* <p>
* If the object has a custom mapping (is of a class implementing the
* interface {@code SQLData}),
* the JDBC driver should call the method {@code SQLData.writeSQL} to
* write it to the SQL data stream.
* If, on the other hand, the object is of a class implementing
* {@code Ref}, {@code Blob}, {@code Clob}, {@code NClob},
* {@code Struct}, {@code java.net.URL},
* or {@code Array}, the driver should pass it to the database as a
* value of the corresponding SQL type.
*<P>
* The default implementation will throw {@code SQLFeatureNotSupportedException}
*
* @param x the object containing the input parameter value
* @param targetSqlType the SQL type to be sent to the database.
* @exception SQLException if a database access error occurs or
* if the Java Object specified by x is an InputStream
* or Reader object and the value of the scale parameter is less
* than zero
* @exception SQLFeatureNotSupportedException if
* the JDBC driver does not support this data type
* @see JDBCType
* @see SQLType
* @since 1.8
*/
default void writeObject(Object x, SQLType targetSqlType) throws SQLException {
throw new SQLFeatureNotSupportedException();
}
}

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.security.*;
/**
* The permission for which the <code>SecurityManager</code> will check
* when code that is running an application with a
* <code>SecurityManager</code> enabled, calls the
* {@code DriverManager.deregisterDriver} method,
* <code>DriverManager.setLogWriter</code> method,
* <code>DriverManager.setLogStream</code> (deprecated) method,
* {@code SyncFactory.setJNDIContext} method,
* {@code SyncFactory.setLogger} method,
* {@code Connection.setNetworktimeout} method,
* or the <code>Connection.abort</code> method.
* If there is no <code>SQLPermission</code> object, these methods
* throw a <code>java.lang.SecurityException</code> as a runtime exception.
* <P>
* A <code>SQLPermission</code> object contains
* a name (also referred to as a "target name") but no actions
* list; there is either a named permission or there is not.
* The target name is the name of the permission (see below). The
* naming convention follows the hierarchical property naming convention.
* In addition, an asterisk
* may appear at the end of the name, following a ".", or by itself, to
* signify a wildcard match. For example: <code>loadLibrary.*</code>
* and <code>*</code> signify a wildcard match,
* while <code>*loadLibrary</code> and <code>a*b</code> do not.
* <P>
* The following table lists all the possible <code>SQLPermission</code> target names.
* The table gives a description of what the permission allows
* and a discussion of the risks of granting code the permission.
*
*
* <table border=1 cellpadding=5 summary="permission target name, what the permission allows, and associated risks">
* <tr>
* <th>Permission Target Name</th>
* <th>What the Permission Allows</th>
* <th>Risks of Allowing this Permission</th>
* </tr>
*
* <tr>
* <td>setLog</td>
* <td>Setting of the logging stream</td>
* <td>This is a dangerous permission to grant.
* The contents of the log may contain usernames and passwords,
* SQL statements, and SQL data.</td>
* </tr>
* <tr>
* <td>callAbort</td>
* <td>Allows the invocation of the {@code Connection} method
* {@code abort}</td>
* <td>Permits an application to terminate a physical connection to a
* database.</td>
* </tr>
* <tr>
* <td>setSyncFactory</td>
* <td>Allows the invocation of the {@code SyncFactory} methods
* {@code setJNDIContext} and {@code setLogger}</td>
* <td>Permits an application to specify the JNDI context from which the
* {@code SyncProvider} implementations can be retrieved from and the logging
* object to be used by the {@code SyncProvider} implementation.</td>
* </tr>
*
* <tr>
* <td>setNetworkTimeout</td>
* <td>Allows the invocation of the {@code Connection} method
* {@code setNetworkTimeout}</td>
* <td>Permits an application to specify the maximum period a
* <code>Connection</code> or
* objects created from the <code>Connection</code>
* will wait for the database to reply to any one request.</td>
* <tr>
* <td>deregisterDriver</td>
* <td>Allows the invocation of the {@code DriverManager}
* method {@code deregisterDriver}</td>
* <td>Permits an application to remove a JDBC driver from the list of
* registered Drivers and release its resources.</td>
* </tr>
* </table>
*<p>
* @since 1.3
* @see java.security.BasicPermission
* @see java.security.Permission
* @see java.security.Permissions
* @see java.security.PermissionCollection
* @see java.lang.SecurityManager
*
*/
public final class SQLPermission extends BasicPermission {
/**
* Creates a new <code>SQLPermission</code> object with the specified name.
* The name is the symbolic name of the <code>SQLPermission</code>.
*
* @param name the name of this <code>SQLPermission</code> object, which must
* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},
* {@code deregisterDriver}, or {@code setNetworkTimeout}
* @throws NullPointerException if <code>name</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>name</code> is empty.
*/
public SQLPermission(String name) {
super(name);
}
/**
* Creates a new <code>SQLPermission</code> object with the specified name.
* The name is the symbolic name of the <code>SQLPermission</code>; the
* actions <code>String</code> is currently unused and should be
* <code>null</code>.
*
* @param name the name of this <code>SQLPermission</code> object, which must
* be either {@code setLog}, {@code callAbort}, {@code setSyncFactory},
* {@code deregisterDriver}, or {@code setNetworkTimeout}
* @param actions should be <code>null</code>
* @throws NullPointerException if <code>name</code> is <code>null</code>.
* @throws IllegalArgumentException if <code>name</code> is empty.
*/
public SQLPermission(String name, String actions) {
super(name, actions);
}
/**
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = -1439323187199563495L;
}

View File

@@ -0,0 +1,175 @@
/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown in situations where a
* previously failed operation might be able to succeed if the application performs
* some recovery steps and retries the entire transaction or in the case of a
* distributed transaction, the transaction branch. At a minimum,
* the recovery operation must include closing the current connection and getting
* a new connection.
*<p>
*
* @since 1.6
*/
public class SQLRecoverableException extends java.sql.SQLException {
/**
* Constructs a <code>SQLRecoverableException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLRecoverableException() {
super();
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLRecoverableException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLRecoverableException(String reason, String SQLState) {
super(reason, SQLState);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLRecoverableException(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLRecoverableException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLRecoverableException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLRecoverableException(String reason, String SQLState, Throwable cause) {
super(reason, SQLState, cause);
}
/**
* Constructs a <code>SQLRecoverableException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLRecoverableException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason, SQLState, vendorCode, cause);
}
private static final long serialVersionUID = -4144386502923131579L;
}

View File

@@ -0,0 +1,173 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value
* is '<i>42</i>', or under vendor-specified conditions. This indicates that the
* in-progress query has violated SQL syntax rules.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLSyntaxErrorException extends SQLNonTransientException {
/**
* Constructs a <code>SQLSyntaxErrorException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLSyntaxErrorException() {
super();
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLSyntaxErrorException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLSyntaxErrorException(String reason, String SQLState) {
super(reason, SQLState);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLSyntaxErrorException(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLSyntaxErrorException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLSyntaxErrorException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLSyntaxErrorException(String reason, String SQLState, Throwable cause) {
super(reason, SQLState, cause);
}
/**
* Constructs a <code>SQLSyntaxErrorException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLSyntaxErrorException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason, SQLState, vendorCode, cause);
}
private static final long serialVersionUID = -1843832610477496053L;
}

View File

@@ -0,0 +1,173 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <P>The subclass of {@link SQLException} thrown when the timeout specified by
* {@code Statement.setQueryTimeout}, {@code DriverManager.setLoginTimeout},
* {@code DataSource.setLoginTimeout},{@code XADataSource.setLoginTimeout}
* has expired.
* <P> This exception does not correspond to a standard SQLState.
*
* @since 1.6
*/
public class SQLTimeoutException extends SQLTransientException {
/**
* Constructs a <code>SQLTimeoutException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLTimeoutException() {
super();
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLTimeoutException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLTimeoutException(String reason, String SQLState) {
super(reason, SQLState);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLTimeoutException(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTimeoutException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTimeoutException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTimeoutException(String reason, String SQLState, Throwable cause) {
super(reason, SQLState, cause);
}
/**
* Constructs a <code>SQLTimeoutException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTimeoutException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason, SQLState, vendorCode, cause);
}
private static final long serialVersionUID = -4487171280562520262L;
}

View File

@@ -0,0 +1,173 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} thrown when the SQLState class value
* is '<i>40</i>', or under vendor-specified conditions. This indicates that the
* current statement was automatically rolled back by the database because
* of deadlock or other transaction serialization failures.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLTransactionRollbackException extends SQLTransientException {
/**
* Constructs a <code>SQLTransactionRollbackException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLTransactionRollbackException() {
super();
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLTransactionRollbackException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLTransactionRollbackException(String reason, String SQLState) {
super(reason, SQLState);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLTransactionRollbackException(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransactionRollbackException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransactionRollbackException(String reason, Throwable cause) {
super(reason, cause);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransactionRollbackException(String reason, String SQLState, Throwable cause) {
super(reason, SQLState, cause);
}
/**
* Constructs a <code>SQLTransactionRollbackException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransactionRollbackException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason, SQLState, vendorCode, cause);
}
private static final long serialVersionUID = 5246680841170837229L;
}

View File

@@ -0,0 +1,174 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} for the SQLState class
* value '<i>08</i>', or under vendor-specified conditions. This indicates
* that the connection operation that failed might be able to succeed if
* the operation is retried without any application-level changes.
* <p>
* Please consult your driver vendor documentation for the vendor-specified
* conditions for which this <code>Exception</code> may be thrown.
* @since 1.6
*/
public class SQLTransientConnectionException extends java.sql.SQLTransientException {
/**
* Constructs a <code>SQLTransientConnectionException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLTransientConnectionException() {
super();
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLTransientConnectionException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLTransientConnectionException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLTransientConnectionException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientConnectionException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code>(which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientConnectionException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientConnectionException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLTransientConnectionException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientConnectionException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -2520155553543391200L;
}

View File

@@ -0,0 +1,172 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The subclass of {@link SQLException} is thrown in situations where a
* previously failed operation might be able to succeed when the operation is
* retried without any intervention by application-level functionality.
*<p>
*
* @since 1.6
*/
public class SQLTransientException extends java.sql.SQLException {
/**
* Constructs a <code>SQLTransientException</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @since 1.6
*/
public SQLTransientException() {
super();
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @since 1.6
*/
public SQLTransientException(String reason) {
super(reason);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @since 1.6
*/
public SQLTransientException(String reason, String SQLState) {
super(reason,SQLState);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor specific exception code
* @since 1.6
*/
public SQLTransientException(String reason, String SQLState, int vendorCode) {
super(reason,SQLState,vendorCode);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientException(Throwable cause) {
super(cause);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientException(String reason, Throwable cause) {
super(reason,cause);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the exception.
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientException(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
}
/**
* Constructs a <code>SQLTransientException</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the exception
* @param SQLState an XOPEN or SQL:2003 code identifying the exception
* @param vendorCode a database vendor-specific exception code
* @param cause the underlying reason for this <code>SQLException</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
* @since 1.6
*/
public SQLTransientException(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
}
private static final long serialVersionUID = -9042733978262274539L;
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* An object that is used to identify a generic SQL type, called a JDBC type or
* a vendor specific data type.
*
* @since 1.8
*/
public interface SQLType {
/**
* Returns the {@code SQLType} name that represents a SQL data type.
*
* @return The name of this {@code SQLType}.
*/
String getName();
/**
* Returns the name of the vendor that supports this data type. The value
* returned typically is the package name for this vendor.
*
* @return The name of the vendor for this data type
*/
String getVendor();
/**
* Returns the vendor specific type number for the data type.
*
* @return An Integer representing the vendor specific data type
*/
Integer getVendorTypeNumber();
}

View File

@@ -0,0 +1,217 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <P>An exception that provides information on database access
* warnings. Warnings are silently chained to the object whose method
* caused it to be reported.
* <P>
* Warnings may be retrieved from <code>Connection</code>, <code>Statement</code>,
* and <code>ResultSet</code> objects. Trying to retrieve a warning on a
* connection after it has been closed will cause an exception to be thrown.
* Similarly, trying to retrieve a warning on a statement after it has been
* closed or on a result set after it has been closed will cause
* an exception to be thrown. Note that closing a statement also
* closes a result set that it might have produced.
*
* @see Connection#getWarnings
* @see Statement#getWarnings
* @see ResultSet#getWarnings
*/
public class SQLWarning extends SQLException {
/**
* Constructs a <code>SQLWarning</code> object
* with a given <code>reason</code>, <code>SQLState</code> and
* <code>vendorCode</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the warning
* @param SQLState an XOPEN or SQL:2003 code identifying the warning
* @param vendorCode a database vendor-specific warning code
*/
public SQLWarning(String reason, String SQLState, int vendorCode) {
super(reason, SQLState, vendorCode);
DriverManager.println("SQLWarning: reason(" + reason +
") SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
}
/**
* Constructs a <code>SQLWarning</code> object
* with a given <code>reason</code> and <code>SQLState</code>.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code
* is initialized to 0.
* <p>
* @param reason a description of the warning
* @param SQLState an XOPEN or SQL:2003 code identifying the warning
*/
public SQLWarning(String reason, String SQLState) {
super(reason, SQLState);
DriverManager.println("SQLWarning: reason(" + reason +
") SQLState(" + SQLState + ")");
}
/**
* Constructs a <code>SQLWarning</code> object
* with a given <code>reason</code>. The <code>SQLState</code>
* is initialized to <code>null</code> and the vendor code is initialized
* to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
* <p>
* @param reason a description of the warning
*/
public SQLWarning(String reason) {
super(reason);
DriverManager.println("SQLWarning: reason(" + reason + ")");
}
/**
* Constructs a <code>SQLWarning</code> object.
* The <code>reason</code>, <code>SQLState</code> are initialized
* to <code>null</code> and the vendor code is initialized to 0.
*
* The <code>cause</code> is not initialized, and may subsequently be
* initialized by a call to the
* {@link Throwable#initCause(java.lang.Throwable)} method.
*
*/
public SQLWarning() {
super();
DriverManager.println("SQLWarning: ");
}
/**
* Constructs a <code>SQLWarning</code> object
* with a given <code>cause</code>.
* The <code>SQLState</code> is initialized
* to <code>null</code> and the vendor code is initialized to 0.
* The <code>reason</code> is initialized to <code>null</code> if
* <code>cause==null</code> or to <code>cause.toString()</code> if
* <code>cause!=null</code>.
* <p>
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
*/
public SQLWarning(Throwable cause) {
super(cause);
DriverManager.println("SQLWarning");
}
/**
* Constructs a <code>SQLWarning</code> object
* with a given
* <code>reason</code> and <code>cause</code>.
* The <code>SQLState</code> is initialized to <code>null</code>
* and the vendor code is initialized to 0.
* <p>
* @param reason a description of the warning
* @param cause the underlying reason for this <code>SQLWarning</code>
* (which is saved for later retrieval by the <code>getCause()</code> method);
* may be null indicating the cause is non-existent or unknown.
*/
public SQLWarning(String reason, Throwable cause) {
super(reason,cause);
DriverManager.println("SQLWarning : reason("+ reason + ")");
}
/**
* Constructs a <code>SQLWarning</code> object
* with a given
* <code>reason</code>, <code>SQLState</code> and <code>cause</code>.
* The vendor code is initialized to 0.
* <p>
* @param reason a description of the warning
* @param SQLState an XOPEN or SQL:2003 code identifying the warning
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
*/
public SQLWarning(String reason, String SQLState, Throwable cause) {
super(reason,SQLState,cause);
DriverManager.println("SQLWarning: reason(" + reason +
") SQLState(" + SQLState + ")");
}
/**
* Constructs a<code>SQLWarning</code> object
* with a given
* <code>reason</code>, <code>SQLState</code>, <code>vendorCode</code>
* and <code>cause</code>.
* <p>
* @param reason a description of the warning
* @param SQLState an XOPEN or SQL:2003 code identifying the warning
* @param vendorCode a database vendor-specific warning code
* @param cause the underlying reason for this <code>SQLWarning</code> (which is saved for later retrieval by the <code>getCause()</code> method); may be null indicating
* the cause is non-existent or unknown.
*/
public SQLWarning(String reason, String SQLState, int vendorCode, Throwable cause) {
super(reason,SQLState,vendorCode,cause);
DriverManager.println("SQLWarning: reason(" + reason +
") SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
}
/**
* Retrieves the warning chained to this <code>SQLWarning</code> object by
* <code>setNextWarning</code>.
*
* @return the next <code>SQLException</code> in the chain; <code>null</code> if none
* @see #setNextWarning
*/
public SQLWarning getNextWarning() {
try {
return ((SQLWarning)getNextException());
} catch (ClassCastException ex) {
// The chained value isn't a SQLWarning.
// This is a programming error by whoever added it to
// the SQLWarning chain. We throw a Java "Error".
throw new Error("SQLWarning chain holds value that is not a SQLWarning");
}
}
/**
* Adds a <code>SQLWarning</code> object to the end of the chain.
*
* @param w the new end of the <code>SQLException</code> chain
* @see #getNextWarning
*/
public void setNextWarning(SQLWarning w) {
setNextException(w);
}
private static final long serialVersionUID = 3917336774604784856L;
}

View File

@@ -0,0 +1,427 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
/**
* The mapping in the JavaTM programming language for the SQL XML type.
* XML is a built-in type that stores an XML value
* as a column value in a row of a database table.
* By default drivers implement an SQLXML object as
* a logical pointer to the XML data
* rather than the data itself.
* An SQLXML object is valid for the duration of the transaction in which it was created.
* <p>
* The SQLXML interface provides methods for accessing the XML value
* as a String, a Reader or Writer, or as a Stream. The XML value
* may also be accessed through a Source or set as a Result, which
* are used with XML Parser APIs such as DOM, SAX, and StAX, as
* well as with XSLT transforms and XPath evaluations.
* <p>
* Methods in the interfaces ResultSet, CallableStatement, and PreparedStatement,
* such as getSQLXML allow a programmer to access an XML value.
* In addition, this interface has methods for updating an XML value.
* <p>
* The XML value of the SQLXML instance may be obtained as a BinaryStream using
* <pre>
* SQLXML sqlxml = resultSet.getSQLXML(column);
* InputStream binaryStream = sqlxml.getBinaryStream();
* </pre>
* For example, to parse an XML value with a DOM parser:
* <pre>
* DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
* Document result = parser.parse(binaryStream);
* </pre>
* or to parse an XML value with a SAX parser to your handler:
* <pre>
* SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
* parser.parse(binaryStream, myHandler);
* </pre>
* or to parse an XML value with a StAX parser:
* <pre>
* XMLInputFactory factory = XMLInputFactory.newInstance();
* XMLStreamReader streamReader = factory.createXMLStreamReader(binaryStream);
* </pre>
* <p>
* Because databases may use an optimized representation for the XML,
* accessing the value through getSource() and
* setResult() can lead to improved processing performance
* without serializing to a stream representation and parsing the XML.
* <p>
* For example, to obtain a DOM Document Node:
* <pre>
* DOMSource domSource = sqlxml.getSource(DOMSource.class);
* Document document = (Document) domSource.getNode();
* </pre>
* or to set the value to a DOM Document Node to myNode:
* <pre>
* DOMResult domResult = sqlxml.setResult(DOMResult.class);
* domResult.setNode(myNode);
* </pre>
* or, to send SAX events to your handler:
* <pre>
* SAXSource saxSource = sqlxml.getSource(SAXSource.class);
* XMLReader xmlReader = saxSource.getXMLReader();
* xmlReader.setContentHandler(myHandler);
* xmlReader.parse(saxSource.getInputSource());
* </pre>
* or, to set the result value from SAX events:
* <pre>
* SAXResult saxResult = sqlxml.setResult(SAXResult.class);
* ContentHandler contentHandler = saxResult.getHandler();
* contentHandler.startDocument();
* // set the XML elements and attributes into the result
* contentHandler.endDocument();
* </pre>
* or, to obtain StAX events:
* <pre>
* StAXSource staxSource = sqlxml.getSource(StAXSource.class);
* XMLStreamReader streamReader = staxSource.getXMLStreamReader();
* </pre>
* or, to set the result value from StAX events:
* <pre>
* StAXResult staxResult = sqlxml.setResult(StAXResult.class);
* XMLStreamWriter streamWriter = staxResult.getXMLStreamWriter();
* </pre>
* or, to perform XSLT transformations on the XML value using the XSLT in xsltFile
* output to file resultFile:
* <pre>
* File xsltFile = new File("a.xslt");
* File myFile = new File("result.xml");
* Transformer xslt = TransformerFactory.newInstance().newTransformer(new StreamSource(xsltFile));
* Source source = sqlxml.getSource(null);
* Result result = new StreamResult(myFile);
* xslt.transform(source, result);
* </pre>
* or, to evaluate an XPath expression on the XML value:
* <pre>
* XPath xpath = XPathFactory.newInstance().newXPath();
* DOMSource domSource = sqlxml.getSource(DOMSource.class);
* Document document = (Document) domSource.getNode();
* String expression = "/foo/@bar";
* String barValue = xpath.evaluate(expression, document);
* </pre>
* To set the XML value to be the result of an XSLT transform:
* <pre>
* File sourceFile = new File("source.xml");
* Transformer xslt = TransformerFactory.newInstance().newTransformer(new StreamSource(xsltFile));
* Source streamSource = new StreamSource(sourceFile);
* Result result = sqlxml.setResult(null);
* xslt.transform(streamSource, result);
* </pre>
* Any Source can be transformed to a Result using the identity transform
* specified by calling newTransformer():
* <pre>
* Transformer identity = TransformerFactory.newInstance().newTransformer();
* Source source = sqlxml.getSource(null);
* File myFile = new File("result.xml");
* Result result = new StreamResult(myFile);
* identity.transform(source, result);
* </pre>
* To write the contents of a Source to standard output:
* <pre>
* Transformer identity = TransformerFactory.newInstance().newTransformer();
* Source source = sqlxml.getSource(null);
* Result result = new StreamResult(System.out);
* identity.transform(source, result);
* </pre>
* To create a DOMSource from a DOMResult:
* <pre>
* DOMSource domSource = new DOMSource(domResult.getNode());
* </pre>
* <p>
* Incomplete or invalid XML values may cause an SQLException when
* set or the exception may occur when execute() occurs. All streams
* must be closed before execute() occurs or an SQLException will be thrown.
* <p>
* Reading and writing XML values to or from an SQLXML object can happen at most once.
* The conceptual states of readable and not readable determine if one
* of the reading APIs will return a value or throw an exception.
* The conceptual states of writable and not writable determine if one
* of the writing APIs will set a value or throw an exception.
* <p>
* The state moves from readable to not readable once free() or any of the
* reading APIs are called: getBinaryStream(), getCharacterStream(), getSource(), and getString().
* Implementations may also change the state to not writable when this occurs.
* <p>
* The state moves from writable to not writeable once free() or any of the
* writing APIs are called: setBinaryStream(), setCharacterStream(), setResult(), and setString().
* Implementations may also change the state to not readable when this occurs.
*
* <p>
* All methods on the <code>SQLXML</code> interface must be fully implemented if the
* JDBC driver supports the data type.
*
* @see javax.xml.parsers
* @see javax.xml.stream
* @see javax.xml.transform
* @see javax.xml.xpath
* @since 1.6
*/
public interface SQLXML
{
/**
* This method closes this object and releases the resources that it held.
* The SQL XML object becomes invalid and neither readable or writeable
* when this method is called.
*
* After <code>free</code> has been called, any attempt to invoke a
* method other than <code>free</code> will result in a <code>SQLException</code>
* being thrown. If <code>free</code> is called multiple times, the subsequent
* calls to <code>free</code> are treated as a no-op.
* @throws SQLException if there is an error freeing the XML value.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void free() throws SQLException;
/**
* Retrieves the XML value designated by this SQLXML instance as a stream.
* The bytes of the input stream are interpreted according to appendix F of the XML 1.0 specification.
* The behavior of this method is the same as ResultSet.getBinaryStream()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not readable when this method is called and
* may also become not writable depending on implementation.
*
* @return a stream containing the XML data.
* @throws SQLException if there is an error processing the XML value.
* An exception is thrown if the state is not readable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
InputStream getBinaryStream() throws SQLException;
/**
* Retrieves a stream that can be used to write the XML value that this SQLXML instance represents.
* The stream begins at position 0.
* The bytes of the stream are interpreted according to appendix F of the XML 1.0 specification
* The behavior of this method is the same as ResultSet.updateBinaryStream()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not writeable when this method is called and
* may also become not readable depending on implementation.
*
* @return a stream to which data can be written.
* @throws SQLException if there is an error processing the XML value.
* An exception is thrown if the state is not writable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
OutputStream setBinaryStream() throws SQLException;
/**
* Retrieves the XML value designated by this SQLXML instance as a java.io.Reader object.
* The format of this stream is defined by org.xml.sax.InputSource,
* where the characters in the stream represent the unicode code points for
* XML according to section 2 and appendix B of the XML 1.0 specification.
* Although an encoding declaration other than unicode may be present,
* the encoding of the stream is unicode.
* The behavior of this method is the same as ResultSet.getCharacterStream()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not readable when this method is called and
* may also become not writable depending on implementation.
*
* @return a stream containing the XML data.
* @throws SQLException if there is an error processing the XML value.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if the stream does not contain valid characters.
* An exception is thrown if the state is not readable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
Reader getCharacterStream() throws SQLException;
/**
* Retrieves a stream to be used to write the XML value that this SQLXML instance represents.
* The format of this stream is defined by org.xml.sax.InputSource,
* where the characters in the stream represent the unicode code points for
* XML according to section 2 and appendix B of the XML 1.0 specification.
* Although an encoding declaration other than unicode may be present,
* the encoding of the stream is unicode.
* The behavior of this method is the same as ResultSet.updateCharacterStream()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not writeable when this method is called and
* may also become not readable depending on implementation.
*
* @return a stream to which data can be written.
* @throws SQLException if there is an error processing the XML value.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if the stream does not contain valid characters.
* An exception is thrown if the state is not writable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
Writer setCharacterStream() throws SQLException;
/**
* Returns a string representation of the XML value designated by this SQLXML instance.
* The format of this String is defined by org.xml.sax.InputSource,
* where the characters in the stream represent the unicode code points for
* XML according to section 2 and appendix B of the XML 1.0 specification.
* Although an encoding declaration other than unicode may be present,
* the encoding of the String is unicode.
* The behavior of this method is the same as ResultSet.getString()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not readable when this method is called and
* may also become not writable depending on implementation.
*
* @return a string representation of the XML value designated by this SQLXML instance.
* @throws SQLException if there is an error processing the XML value.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if the stream does not contain valid characters.
* An exception is thrown if the state is not readable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
String getString() throws SQLException;
/**
* Sets the XML value designated by this SQLXML instance to the given String representation.
* The format of this String is defined by org.xml.sax.InputSource,
* where the characters in the stream represent the unicode code points for
* XML according to section 2 and appendix B of the XML 1.0 specification.
* Although an encoding declaration other than unicode may be present,
* the encoding of the String is unicode.
* The behavior of this method is the same as ResultSet.updateString()
* when the designated column of the ResultSet has a type java.sql.Types of SQLXML.
* <p>
* The SQL XML object becomes not writeable when this method is called and
* may also become not readable depending on implementation.
*
* @param value the XML value
* @throws SQLException if there is an error processing the XML value.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if the stream does not contain valid characters.
* An exception is thrown if the state is not writable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
void setString(String value) throws SQLException;
/**
* Returns a Source for reading the XML value designated by this SQLXML instance.
* Sources are used as inputs to XML parsers and XSLT transformers.
* <p>
* Sources for XML parsers will have namespace processing on by default.
* The systemID of the Source is implementation dependent.
* <p>
* The SQL XML object becomes not readable when this method is called and
* may also become not writable depending on implementation.
* <p>
* Note that SAX is a callback architecture, so a returned
* SAXSource should then be set with a content handler that will
* receive the SAX events from parsing. The content handler
* will receive callbacks based on the contents of the XML.
* <pre>
* SAXSource saxSource = sqlxml.getSource(SAXSource.class);
* XMLReader xmlReader = saxSource.getXMLReader();
* xmlReader.setContentHandler(myHandler);
* xmlReader.parse(saxSource.getInputSource());
* </pre>
*
* @param <T> the type of the class modeled by this Class object
* @param sourceClass The class of the source, or null.
* If the class is null, a vendor specific Source implementation will be returned.
* The following classes are supported at a minimum:
* <pre>
* javax.xml.transform.dom.DOMSource - returns a DOMSource
* javax.xml.transform.sax.SAXSource - returns a SAXSource
* javax.xml.transform.stax.StAXSource - returns a StAXSource
* javax.xml.transform.stream.StreamSource - returns a StreamSource
* </pre>
* @return a Source for reading the XML value.
* @throws SQLException if there is an error processing the XML value
* or if this feature is not supported.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if an XML parser exception occurs.
* An exception is thrown if the state is not readable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
<T extends Source> T getSource(Class<T> sourceClass) throws SQLException;
/**
* Returns a Result for setting the XML value designated by this SQLXML instance.
* <p>
* The systemID of the Result is implementation dependent.
* <p>
* The SQL XML object becomes not writeable when this method is called and
* may also become not readable depending on implementation.
* <p>
* Note that SAX is a callback architecture and the returned
* SAXResult has a content handler assigned that will receive the
* SAX events based on the contents of the XML. Call the content
* handler with the contents of the XML document to assign the values.
* <pre>
* SAXResult saxResult = sqlxml.setResult(SAXResult.class);
* ContentHandler contentHandler = saxResult.getXMLReader().getContentHandler();
* contentHandler.startDocument();
* // set the XML elements and attributes into the result
* contentHandler.endDocument();
* </pre>
*
* @param <T> the type of the class modeled by this Class object
* @param resultClass The class of the result, or null.
* If resultClass is null, a vendor specific Result implementation will be returned.
* The following classes are supported at a minimum:
* <pre>
* javax.xml.transform.dom.DOMResult - returns a DOMResult
* javax.xml.transform.sax.SAXResult - returns a SAXResult
* javax.xml.transform.stax.StAXResult - returns a StAXResult
* javax.xml.transform.stream.StreamResult - returns a StreamResult
* </pre>
* @return Returns a Result for setting the XML value.
* @throws SQLException if there is an error processing the XML value
* or if this feature is not supported.
* The getCause() method of the exception may provide a more detailed exception, for example,
* if an XML parser exception occurs.
* An exception is thrown if the state is not writable.
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.6
*/
<T extends Result> T setResult(Class<T> resultClass) throws SQLException;
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* The representation of a savepoint, which is a point within
* the current transaction that can be referenced from the
* <code>Connection.rollback</code> method. When a transaction
* is rolled back to a savepoint all changes made after that
* savepoint are undone.
* <p>
* Savepoints can be either named or unnamed. Unnamed savepoints
* are identified by an ID generated by the underlying data source.
*
* @since 1.4
*/
public interface Savepoint {
/**
* Retrieves the generated ID for the savepoint that this
* <code>Savepoint</code> object represents.
* @return the numeric ID of this savepoint
* @exception SQLException if this is a named savepoint
* @since 1.4
*/
int getSavepointId() throws SQLException;
/**
* Retrieves the name of the savepoint that this <code>Savepoint</code>
* object represents.
* @return the name of this savepoint
* @exception SQLException if this is an un-named savepoint
* @since 1.4
*/
String getSavepointName() throws SQLException;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <p>The standard mapping in the Java programming language for an SQL
* structured type. A <code>Struct</code> object contains a
* value for each attribute of the SQL structured type that
* it represents.
* By default, an instance of<code>Struct</code> is valid as long as the
* application has a reference to it.
* <p>
* All methods on the <code>Struct</code> interface must be fully implemented if the
* JDBC driver supports the data type.
* @since 1.2
*/
public interface Struct {
/**
* Retrieves the SQL type name of the SQL structured type
* that this <code>Struct</code> object represents.
*
* @return the fully-qualified type name of the SQL structured
* type for which this <code>Struct</code> object
* is the generic representation
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
String getSQLTypeName() throws SQLException;
/**
* Produces the ordered values of the attributes of the SQL
* structured type that this <code>Struct</code> object represents.
* As individual attributes are processed, this method uses the type map
* associated with the
* connection for customizations of the type mappings.
* If there is no
* entry in the connection's type map that matches the structured
* type that an attribute represents,
* the driver uses the standard mapping.
* <p>
* Conceptually, this method calls the method
* <code>getObject</code> on each attribute
* of the structured type and returns a Java array containing
* the result.
*
* @return an array containing the ordered attribute values
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object[] getAttributes() throws SQLException;
/**
* Produces the ordered values of the attributes of the SQL
* structured type that this <code>Struct</code> object represents.
* As individual attributes are processed, this method uses the given type map
* for customizations of the type mappings.
* If there is no
* entry in the given type map that matches the structured
* type that an attribute represents,
* the driver uses the standard mapping. This method never
* uses the type map associated with the connection.
* <p>
* Conceptually, this method calls the method
* <code>getObject</code> on each attribute
* of the structured type and returns a Java array containing
* the result.
*
* @param map a mapping of SQL type names to Java classes
* @return an array containing the ordered attribute values
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.2
*/
Object[] getAttributes(java.util.Map<String,Class<?>> map)
throws SQLException;
}

View File

@@ -0,0 +1,293 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.time.Instant;
import java.time.LocalTime;
/**
* <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
* API to identify this as an SQL <code>TIME</code> value. The <code>Time</code>
* class adds formatting and
* parsing operations to support the JDBC escape syntax for time
* values.
* <p>The date components should be set to the "zero epoch"
* value of January 1, 1970 and should not be accessed.
*/
public class Time extends java.util.Date {
/**
* Constructs a <code>Time</code> object initialized with the
* given values for the hour, minute, and second.
* The driver sets the date components to January 1, 1970.
* Any method that attempts to access the date components of a
* <code>Time</code> object will throw a
* <code>java.lang.IllegalArgumentException</code>.
* <P>
* The result is undefined if a given argument is out of bounds.
*
* @param hour 0 to 23
* @param minute 0 to 59
* @param second 0 to 59
*
* @deprecated Use the constructor that takes a milliseconds value
* in place of this constructor
*/
@Deprecated
public Time(int hour, int minute, int second) {
super(70, 0, 1, hour, minute, second);
}
/**
* Constructs a <code>Time</code> object using a milliseconds time value.
*
* @param time milliseconds since January 1, 1970, 00:00:00 GMT;
* a negative number is milliseconds before
* January 1, 1970, 00:00:00 GMT
*/
public Time(long time) {
super(time);
}
/**
* Sets a <code>Time</code> object using a milliseconds time value.
*
* @param time milliseconds since January 1, 1970, 00:00:00 GMT;
* a negative number is milliseconds before
* January 1, 1970, 00:00:00 GMT
*/
public void setTime(long time) {
super.setTime(time);
}
/**
* Converts a string in JDBC time escape format to a <code>Time</code> value.
*
* @param s time in format "hh:mm:ss"
* @return a corresponding <code>Time</code> object
*/
public static Time valueOf(String s) {
int hour;
int minute;
int second;
int firstColon;
int secondColon;
if (s == null) throw new java.lang.IllegalArgumentException();
firstColon = s.indexOf(':');
secondColon = s.indexOf(':', firstColon+1);
if ((firstColon > 0) & (secondColon > 0) &
(secondColon < s.length()-1)) {
hour = Integer.parseInt(s.substring(0, firstColon));
minute =
Integer.parseInt(s.substring(firstColon+1, secondColon));
second = Integer.parseInt(s.substring(secondColon+1));
} else {
throw new java.lang.IllegalArgumentException();
}
return new Time(hour, minute, second);
}
/**
* Formats a time in JDBC time escape format.
*
* @return a <code>String</code> in hh:mm:ss format
*/
@SuppressWarnings("deprecation")
public String toString () {
int hour = super.getHours();
int minute = super.getMinutes();
int second = super.getSeconds();
String hourString;
String minuteString;
String secondString;
if (hour < 10) {
hourString = "0" + hour;
} else {
hourString = Integer.toString(hour);
}
if (minute < 10) {
minuteString = "0" + minute;
} else {
minuteString = Integer.toString(minute);
}
if (second < 10) {
secondString = "0" + second;
} else {
secondString = Integer.toString(second);
}
return (hourString + ":" + minuteString + ":" + secondString);
}
// Override all the date operations inherited from java.util.Date;
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a year component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #setYear
*/
@Deprecated
public int getYear() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a month component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #setMonth
*/
@Deprecated
public int getMonth() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a day component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
*/
@Deprecated
public int getDay() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a date component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #setDate
*/
@Deprecated
public int getDate() {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a year component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #getYear
*/
@Deprecated
public void setYear(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a month component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #getMonth
*/
@Deprecated
public void setMonth(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* This method is deprecated and should not be used because SQL <code>TIME</code>
* values do not have a date component.
*
* @deprecated
* @exception java.lang.IllegalArgumentException if this
* method is invoked
* @see #getDate
*/
@Deprecated
public void setDate(int i) {
throw new java.lang.IllegalArgumentException();
}
/**
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = 8397324403548013681L;
/**
* Obtains an instance of {@code Time} from a {@link LocalTime} object
* with the same hour, minute and second time value as the given
* {@code LocalTime}.
*
* @param time a {@code LocalTime} to convert
* @return a {@code Time} object
* @exception NullPointerException if {@code time} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Time valueOf(LocalTime time) {
return new Time(time.getHour(), time.getMinute(), time.getSecond());
}
/**
* Converts this {@code Time} object to a {@code LocalTime}.
* <p>
* The conversion creates a {@code LocalTime} that represents the same
* hour, minute, and second time value as this {@code Time}.
*
* @return a {@code LocalTime} object representing the same time value
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalTime toLocalTime() {
return LocalTime.of(getHours(), getMinutes(), getSeconds());
}
/**
* This method always throws an UnsupportedOperationException and should
* not be used because SQL {@code Time} values do not have a date
* component.
*
* @exception java.lang.UnsupportedOperationException if this method is invoked
*/
@Override
public Instant toInstant() {
throw new java.lang.UnsupportedOperationException();
}
}

View File

@@ -0,0 +1,619 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.StringTokenizer;
/**
* <P>A thin wrapper around <code>java.util.Date</code> that allows
* the JDBC API to identify this as an SQL <code>TIMESTAMP</code> value.
* It adds the ability
* to hold the SQL <code>TIMESTAMP</code> fractional seconds value, by allowing
* the specification of fractional seconds to a precision of nanoseconds.
* A Timestamp also provides formatting and
* parsing operations to support the JDBC escape syntax for timestamp values.
*
* <p>The precision of a Timestamp object is calculated to be either:
* <ul>
* <li><code>19 </code>, which is the number of characters in yyyy-mm-dd hh:mm:ss
* <li> <code> 20 + s </code>, which is the number
* of characters in the yyyy-mm-dd hh:mm:ss.[fff...] and <code>s</code> represents the scale of the given Timestamp,
* its fractional seconds precision.
*</ul>
*
* <P><B>Note:</B> This type is a composite of a <code>java.util.Date</code> and a
* separate nanoseconds value. Only integral seconds are stored in the
* <code>java.util.Date</code> component. The fractional seconds - the nanos - are
* separate. The <code>Timestamp.equals(Object)</code> method never returns
* <code>true</code> when passed an object
* that isn't an instance of <code>java.sql.Timestamp</code>,
* because the nanos component of a date is unknown.
* As a result, the <code>Timestamp.equals(Object)</code>
* method is not symmetric with respect to the
* <code>java.util.Date.equals(Object)</code>
* method. Also, the <code>hashCode</code> method uses the underlying
* <code>java.util.Date</code>
* implementation and therefore does not include nanos in its computation.
* <P>
* Due to the differences between the <code>Timestamp</code> class
* and the <code>java.util.Date</code>
* class mentioned above, it is recommended that code not view
* <code>Timestamp</code> values generically as an instance of
* <code>java.util.Date</code>. The
* inheritance relationship between <code>Timestamp</code>
* and <code>java.util.Date</code> really
* denotes implementation inheritance, and not type inheritance.
*/
public class Timestamp extends java.util.Date {
/**
* Constructs a <code>Timestamp</code> object initialized
* with the given values.
*
* @param year the year minus 1900
* @param month 0 to 11
* @param date 1 to 31
* @param hour 0 to 23
* @param minute 0 to 59
* @param second 0 to 59
* @param nano 0 to 999,999,999
* @deprecated instead use the constructor <code>Timestamp(long millis)</code>
* @exception IllegalArgumentException if the nano argument is out of bounds
*/
@Deprecated
public Timestamp(int year, int month, int date,
int hour, int minute, int second, int nano) {
super(year, month, date, hour, minute, second);
if (nano > 999999999 || nano < 0) {
throw new IllegalArgumentException("nanos > 999999999 or < 0");
}
nanos = nano;
}
/**
* Constructs a <code>Timestamp</code> object
* using a milliseconds time value. The
* integral seconds are stored in the underlying date value; the
* fractional seconds are stored in the <code>nanos</code> field of
* the <code>Timestamp</code> object.
*
* @param time milliseconds since January 1, 1970, 00:00:00 GMT.
* A negative number is the number of milliseconds before
* January 1, 1970, 00:00:00 GMT.
* @see java.util.Calendar
*/
public Timestamp(long time) {
super((time/1000)*1000);
nanos = (int)((time%1000) * 1000000);
if (nanos < 0) {
nanos = 1000000000 + nanos;
super.setTime(((time/1000)-1)*1000);
}
}
/**
* Sets this <code>Timestamp</code> object to represent a point in time that is
* <tt>time</tt> milliseconds after January 1, 1970 00:00:00 GMT.
*
* @param time the number of milliseconds.
* @see #getTime
* @see #Timestamp(long time)
* @see java.util.Calendar
*/
public void setTime(long time) {
super.setTime((time/1000)*1000);
nanos = (int)((time%1000) * 1000000);
if (nanos < 0) {
nanos = 1000000000 + nanos;
super.setTime(((time/1000)-1)*1000);
}
}
/**
* Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT
* represented by this <code>Timestamp</code> object.
*
* @return the number of milliseconds since January 1, 1970, 00:00:00 GMT
* represented by this date.
* @see #setTime
*/
public long getTime() {
long time = super.getTime();
return (time + (nanos / 1000000));
}
/**
* @serial
*/
private int nanos;
/**
* Converts a <code>String</code> object in JDBC timestamp escape format to a
* <code>Timestamp</code> value.
*
* @param s timestamp in format <code>yyyy-[m]m-[d]d hh:mm:ss[.f...]</code>. The
* fractional seconds may be omitted. The leading zero for <code>mm</code>
* and <code>dd</code> may also be omitted.
*
* @return corresponding <code>Timestamp</code> value
* @exception java.lang.IllegalArgumentException if the given argument
* does not have the format <code>yyyy-[m]m-[d]d hh:mm:ss[.f...]</code>
*/
public static Timestamp valueOf(String s) {
final int YEAR_LENGTH = 4;
final int MONTH_LENGTH = 2;
final int DAY_LENGTH = 2;
final int MAX_MONTH = 12;
final int MAX_DAY = 31;
String date_s;
String time_s;
String nanos_s;
int year = 0;
int month = 0;
int day = 0;
int hour;
int minute;
int second;
int a_nanos = 0;
int firstDash;
int secondDash;
int dividingSpace;
int firstColon = 0;
int secondColon = 0;
int period = 0;
String formatError = "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]";
String zeros = "000000000";
String delimiterDate = "-";
String delimiterTime = ":";
if (s == null) throw new java.lang.IllegalArgumentException("null string");
// Split the string into date and time components
s = s.trim();
dividingSpace = s.indexOf(' ');
if (dividingSpace > 0) {
date_s = s.substring(0,dividingSpace);
time_s = s.substring(dividingSpace+1);
} else {
throw new java.lang.IllegalArgumentException(formatError);
}
// Parse the date
firstDash = date_s.indexOf('-');
secondDash = date_s.indexOf('-', firstDash+1);
// Parse the time
if (time_s == null)
throw new java.lang.IllegalArgumentException(formatError);
firstColon = time_s.indexOf(':');
secondColon = time_s.indexOf(':', firstColon+1);
period = time_s.indexOf('.', secondColon+1);
// Convert the date
boolean parsedDate = false;
if ((firstDash > 0) && (secondDash > 0) && (secondDash < date_s.length() - 1)) {
String yyyy = date_s.substring(0, firstDash);
String mm = date_s.substring(firstDash + 1, secondDash);
String dd = date_s.substring(secondDash + 1);
if (yyyy.length() == YEAR_LENGTH &&
(mm.length() >= 1 && mm.length() <= MONTH_LENGTH) &&
(dd.length() >= 1 && dd.length() <= DAY_LENGTH)) {
year = Integer.parseInt(yyyy);
month = Integer.parseInt(mm);
day = Integer.parseInt(dd);
if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
parsedDate = true;
}
}
}
if (! parsedDate) {
throw new java.lang.IllegalArgumentException(formatError);
}
// Convert the time; default missing nanos
if ((firstColon > 0) & (secondColon > 0) &
(secondColon < time_s.length()-1)) {
hour = Integer.parseInt(time_s.substring(0, firstColon));
minute =
Integer.parseInt(time_s.substring(firstColon+1, secondColon));
if ((period > 0) & (period < time_s.length()-1)) {
second =
Integer.parseInt(time_s.substring(secondColon+1, period));
nanos_s = time_s.substring(period+1);
if (nanos_s.length() > 9)
throw new java.lang.IllegalArgumentException(formatError);
if (!Character.isDigit(nanos_s.charAt(0)))
throw new java.lang.IllegalArgumentException(formatError);
nanos_s = nanos_s + zeros.substring(0,9-nanos_s.length());
a_nanos = Integer.parseInt(nanos_s);
} else if (period > 0) {
throw new java.lang.IllegalArgumentException(formatError);
} else {
second = Integer.parseInt(time_s.substring(secondColon+1));
}
} else {
throw new java.lang.IllegalArgumentException(formatError);
}
return new Timestamp(year - 1900, month - 1, day, hour, minute, second, a_nanos);
}
/**
* Formats a timestamp in JDBC timestamp escape format.
* <code>yyyy-mm-dd hh:mm:ss.fffffffff</code>,
* where <code>ffffffffff</code> indicates nanoseconds.
* <P>
* @return a <code>String</code> object in
* <code>yyyy-mm-dd hh:mm:ss.fffffffff</code> format
*/
@SuppressWarnings("deprecation")
public String toString () {
int year = super.getYear() + 1900;
int month = super.getMonth() + 1;
int day = super.getDate();
int hour = super.getHours();
int minute = super.getMinutes();
int second = super.getSeconds();
String yearString;
String monthString;
String dayString;
String hourString;
String minuteString;
String secondString;
String nanosString;
String zeros = "000000000";
String yearZeros = "0000";
StringBuffer timestampBuf;
if (year < 1000) {
// Add leading zeros
yearString = "" + year;
yearString = yearZeros.substring(0, (4-yearString.length())) +
yearString;
} else {
yearString = "" + year;
}
if (month < 10) {
monthString = "0" + month;
} else {
monthString = Integer.toString(month);
}
if (day < 10) {
dayString = "0" + day;
} else {
dayString = Integer.toString(day);
}
if (hour < 10) {
hourString = "0" + hour;
} else {
hourString = Integer.toString(hour);
}
if (minute < 10) {
minuteString = "0" + minute;
} else {
minuteString = Integer.toString(minute);
}
if (second < 10) {
secondString = "0" + second;
} else {
secondString = Integer.toString(second);
}
if (nanos == 0) {
nanosString = "0";
} else {
nanosString = Integer.toString(nanos);
// Add leading zeros
nanosString = zeros.substring(0, (9-nanosString.length())) +
nanosString;
// Truncate trailing zeros
char[] nanosChar = new char[nanosString.length()];
nanosString.getChars(0, nanosString.length(), nanosChar, 0);
int truncIndex = 8;
while (nanosChar[truncIndex] == '0') {
truncIndex--;
}
nanosString = new String(nanosChar, 0, truncIndex + 1);
}
// do a string buffer here instead.
timestampBuf = new StringBuffer(20+nanosString.length());
timestampBuf.append(yearString);
timestampBuf.append("-");
timestampBuf.append(monthString);
timestampBuf.append("-");
timestampBuf.append(dayString);
timestampBuf.append(" ");
timestampBuf.append(hourString);
timestampBuf.append(":");
timestampBuf.append(minuteString);
timestampBuf.append(":");
timestampBuf.append(secondString);
timestampBuf.append(".");
timestampBuf.append(nanosString);
return (timestampBuf.toString());
}
/**
* Gets this <code>Timestamp</code> object's <code>nanos</code> value.
*
* @return this <code>Timestamp</code> object's fractional seconds component
* @see #setNanos
*/
public int getNanos() {
return nanos;
}
/**
* Sets this <code>Timestamp</code> object's <code>nanos</code> field
* to the given value.
*
* @param n the new fractional seconds component
* @exception java.lang.IllegalArgumentException if the given argument
* is greater than 999999999 or less than 0
* @see #getNanos
*/
public void setNanos(int n) {
if (n > 999999999 || n < 0) {
throw new IllegalArgumentException("nanos > 999999999 or < 0");
}
nanos = n;
}
/**
* Tests to see if this <code>Timestamp</code> object is
* equal to the given <code>Timestamp</code> object.
*
* @param ts the <code>Timestamp</code> value to compare with
* @return <code>true</code> if the given <code>Timestamp</code>
* object is equal to this <code>Timestamp</code> object;
* <code>false</code> otherwise
*/
public boolean equals(Timestamp ts) {
if (super.equals(ts)) {
if (nanos == ts.nanos) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* Tests to see if this <code>Timestamp</code> object is
* equal to the given object.
*
* This version of the method <code>equals</code> has been added
* to fix the incorrect
* signature of <code>Timestamp.equals(Timestamp)</code> and to preserve backward
* compatibility with existing class files.
*
* Note: This method is not symmetric with respect to the
* <code>equals(Object)</code> method in the base class.
*
* @param ts the <code>Object</code> value to compare with
* @return <code>true</code> if the given <code>Object</code> is an instance
* of a <code>Timestamp</code> that
* is equal to this <code>Timestamp</code> object;
* <code>false</code> otherwise
*/
public boolean equals(java.lang.Object ts) {
if (ts instanceof Timestamp) {
return this.equals((Timestamp)ts);
} else {
return false;
}
}
/**
* Indicates whether this <code>Timestamp</code> object is
* earlier than the given <code>Timestamp</code> object.
*
* @param ts the <code>Timestamp</code> value to compare with
* @return <code>true</code> if this <code>Timestamp</code> object is earlier;
* <code>false</code> otherwise
*/
public boolean before(Timestamp ts) {
return compareTo(ts) < 0;
}
/**
* Indicates whether this <code>Timestamp</code> object is
* later than the given <code>Timestamp</code> object.
*
* @param ts the <code>Timestamp</code> value to compare with
* @return <code>true</code> if this <code>Timestamp</code> object is later;
* <code>false</code> otherwise
*/
public boolean after(Timestamp ts) {
return compareTo(ts) > 0;
}
/**
* Compares this <code>Timestamp</code> object to the given
* <code>Timestamp</code> object.
*
* @param ts the <code>Timestamp</code> object to be compared to
* this <code>Timestamp</code> object
* @return the value <code>0</code> if the two <code>Timestamp</code>
* objects are equal; a value less than <code>0</code> if this
* <code>Timestamp</code> object is before the given argument;
* and a value greater than <code>0</code> if this
* <code>Timestamp</code> object is after the given argument.
* @since 1.4
*/
public int compareTo(Timestamp ts) {
long thisTime = this.getTime();
long anotherTime = ts.getTime();
int i = (thisTime<anotherTime ? -1 :(thisTime==anotherTime?0 :1));
if (i == 0) {
if (nanos > ts.nanos) {
return 1;
} else if (nanos < ts.nanos) {
return -1;
}
}
return i;
}
/**
* Compares this <code>Timestamp</code> object to the given
* <code>Date</code> object.
*
* @param o the <code>Date</code> to be compared to
* this <code>Timestamp</code> object
* @return the value <code>0</code> if this <code>Timestamp</code> object
* and the given object are equal; a value less than <code>0</code>
* if this <code>Timestamp</code> object is before the given argument;
* and a value greater than <code>0</code> if this
* <code>Timestamp</code> object is after the given argument.
*
* @since 1.5
*/
public int compareTo(java.util.Date o) {
if(o instanceof Timestamp) {
// When Timestamp instance compare it with a Timestamp
// Hence it is basically calling this.compareTo((Timestamp))o);
// Note typecasting is safe because o is instance of Timestamp
return compareTo((Timestamp)o);
} else {
// When Date doing a o.compareTo(this)
// will give wrong results.
Timestamp ts = new Timestamp(o.getTime());
return this.compareTo(ts);
}
}
/**
* {@inheritDoc}
*
* The {@code hashCode} method uses the underlying {@code java.util.Date}
* implementation and therefore does not include nanos in its computation.
*
*/
@Override
public int hashCode() {
return super.hashCode();
}
static final long serialVersionUID = 2745179027874758501L;
private static final int MILLIS_PER_SECOND = 1000;
/**
* Obtains an instance of {@code Timestamp} from a {@code LocalDateTime}
* object, with the same year, month, day of month, hours, minutes,
* seconds and nanos date-time value as the provided {@code LocalDateTime}.
* <p>
* The provided {@code LocalDateTime} is interpreted as the local
* date-time in the local time zone.
*
* @param dateTime a {@code LocalDateTime} to convert
* @return a {@code Timestamp} object
* @exception NullPointerException if {@code dateTime} is null.
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Timestamp valueOf(LocalDateTime dateTime) {
return new Timestamp(dateTime.getYear() - 1900,
dateTime.getMonthValue() - 1,
dateTime.getDayOfMonth(),
dateTime.getHour(),
dateTime.getMinute(),
dateTime.getSecond(),
dateTime.getNano());
}
/**
* Converts this {@code Timestamp} object to a {@code LocalDateTime}.
* <p>
* The conversion creates a {@code LocalDateTime} that represents the
* same year, month, day of month, hours, minutes, seconds and nanos
* date-time value as this {@code Timestamp} in the local time zone.
*
* @return a {@code LocalDateTime} object representing the same date-time value
* @since 1.8
*/
@SuppressWarnings("deprecation")
public LocalDateTime toLocalDateTime() {
return LocalDateTime.of(getYear() + 1900,
getMonth() + 1,
getDate(),
getHours(),
getMinutes(),
getSeconds(),
getNanos());
}
/**
* Obtains an instance of {@code Timestamp} from an {@link Instant} object.
* <p>
* {@code Instant} can store points on the time-line further in the future
* and further in the past than {@code Date}. In this scenario, this method
* will throw an exception.
*
* @param instant the instant to convert
* @return an {@code Timestamp} representing the same point on the time-line as
* the provided instant
* @exception NullPointerException if {@code instant} is null.
* @exception IllegalArgumentException if the instant is too large to
* represent as a {@code Timesamp}
* @since 1.8
*/
public static Timestamp from(Instant instant) {
try {
Timestamp stamp = new Timestamp(instant.getEpochSecond() * MILLIS_PER_SECOND);
stamp.nanos = instant.getNano();
return stamp;
} catch (ArithmeticException ex) {
throw new IllegalArgumentException(ex);
}
}
/**
* Converts this {@code Timestamp} object to an {@code Instant}.
* <p>
* The conversion creates an {@code Instant} that represents the same
* point on the time-line as this {@code Timestamp}.
*
* @return an instant representing the same point on the time-line
* @since 1.8
*/
@Override
public Instant toInstant() {
return Instant.ofEpochSecond(super.getTime() / MILLIS_PER_SECOND, nanos);
}
}

View File

@@ -0,0 +1,342 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* <P>The class that defines the constants that are used to identify generic
* SQL types, called JDBC types.
* <p>
* This class is never instantiated.
*/
public class Types {
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>BIT</code>.
*/
public final static int BIT = -7;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>TINYINT</code>.
*/
public final static int TINYINT = -6;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>SMALLINT</code>.
*/
public final static int SMALLINT = 5;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>INTEGER</code>.
*/
public final static int INTEGER = 4;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>BIGINT</code>.
*/
public final static int BIGINT = -5;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>FLOAT</code>.
*/
public final static int FLOAT = 6;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>REAL</code>.
*/
public final static int REAL = 7;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>DOUBLE</code>.
*/
public final static int DOUBLE = 8;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>NUMERIC</code>.
*/
public final static int NUMERIC = 2;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>DECIMAL</code>.
*/
public final static int DECIMAL = 3;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>CHAR</code>.
*/
public final static int CHAR = 1;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>VARCHAR</code>.
*/
public final static int VARCHAR = 12;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>LONGVARCHAR</code>.
*/
public final static int LONGVARCHAR = -1;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>DATE</code>.
*/
public final static int DATE = 91;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>TIME</code>.
*/
public final static int TIME = 92;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>TIMESTAMP</code>.
*/
public final static int TIMESTAMP = 93;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>BINARY</code>.
*/
public final static int BINARY = -2;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>VARBINARY</code>.
*/
public final static int VARBINARY = -3;
/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* <code>LONGVARBINARY</code>.
*/
public final static int LONGVARBINARY = -4;
/**
* <P>The constant in the Java programming language
* that identifies the generic SQL value
* <code>NULL</code>.
*/
public final static int NULL = 0;
/**
* The constant in the Java programming language that indicates
* that the SQL type is database-specific and
* gets mapped to a Java object that can be accessed via
* the methods <code>getObject</code> and <code>setObject</code>.
*/
public final static int OTHER = 1111;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>JAVA_OBJECT</code>.
* @since 1.2
*/
public final static int JAVA_OBJECT = 2000;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>DISTINCT</code>.
* @since 1.2
*/
public final static int DISTINCT = 2001;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>STRUCT</code>.
* @since 1.2
*/
public final static int STRUCT = 2002;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>ARRAY</code>.
* @since 1.2
*/
public final static int ARRAY = 2003;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>BLOB</code>.
* @since 1.2
*/
public final static int BLOB = 2004;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>CLOB</code>.
* @since 1.2
*/
public final static int CLOB = 2005;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* <code>REF</code>.
* @since 1.2
*/
public final static int REF = 2006;
/**
* The constant in the Java programming language, somtimes referred to
* as a type code, that identifies the generic SQL type <code>DATALINK</code>.
*
* @since 1.4
*/
public final static int DATALINK = 70;
/**
* The constant in the Java programming language, somtimes referred to
* as a type code, that identifies the generic SQL type <code>BOOLEAN</code>.
*
* @since 1.4
*/
public final static int BOOLEAN = 16;
//------------------------- JDBC 4.0 -----------------------------------
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>ROWID</code>
*
* @since 1.6
*
*/
public final static int ROWID = -8;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>NCHAR</code>
*
* @since 1.6
*/
public static final int NCHAR = -15;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>NVARCHAR</code>.
*
* @since 1.6
*/
public static final int NVARCHAR = -9;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>LONGNVARCHAR</code>.
*
* @since 1.6
*/
public static final int LONGNVARCHAR = -16;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>NCLOB</code>.
*
* @since 1.6
*/
public static final int NCLOB = 2011;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type <code>XML</code>.
*
* @since 1.6
*/
public static final int SQLXML = 2009;
//--------------------------JDBC 4.2 -----------------------------
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type {@code REF CURSOR}.
*
* @since 1.8
*/
public static final int REF_CURSOR = 2012;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* {@code TIME WITH TIMEZONE}.
*
* @since 1.8
*/
public static final int TIME_WITH_TIMEZONE = 2013;
/**
* The constant in the Java programming language, sometimes referred to
* as a type code, that identifies the generic SQL type
* {@code TIMESTAMP WITH TIMEZONE}.
*
* @since 1.8
*/
public static final int TIMESTAMP_WITH_TIMEZONE = 2014;
// Prevent instantiation
private Types() {}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.sql;
/**
* Interface for JDBC classes which provide the ability to retrieve the delegate instance when the instance
* in question is in fact a proxy class.
* <p>
* The wrapper pattern is employed by many JDBC driver implementations to provide extensions beyond
* the traditional JDBC API that are specific to a data source. Developers may wish to gain access to
* these resources that are wrapped (the delegates) as proxy class instances representing the
* the actual resources. This interface describes a standard mechanism to access
* these wrapped resources
* represented by their proxy, to permit direct access to the resource delegates.
*
* @since 1.6
*/
public interface Wrapper {
/**
* Returns an object that implements the given interface to allow access to
* non-standard methods, or standard methods not exposed by the proxy.
*
* If the receiver implements the interface then the result is the receiver
* or a proxy for the receiver. If the receiver is a wrapper
* and the wrapped object implements the interface then the result is the
* wrapped object or a proxy for the wrapped object. Otherwise return the
* the result of calling <code>unwrap</code> recursively on the wrapped object
* or a proxy for that result. If the receiver is not a
* wrapper and does not implement the interface, then an <code>SQLException</code> is thrown.
*
* @param <T> the type of the class modeled by this Class object
* @param iface A Class defining an interface that the result must implement.
* @return an object that implements the interface. May be a proxy for the actual implementing object.
* @throws java.sql.SQLException If no object found that implements the interface
* @since 1.6
*/
<T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException;
/**
* Returns true if this either implements the interface argument or is directly or indirectly a wrapper
* for an object that does. Returns false otherwise. If this implements the interface then return true,
* else if this is a wrapper then return the result of recursively calling <code>isWrapperFor</code> on the wrapped
* object. If this does not implement the interface and is not a wrapper, return false.
* This method should be implemented as a low-cost operation compared to <code>unwrap</code> so that
* callers can use this method to avoid expensive <code>unwrap</code> calls that may fail. If this method
* returns true then calling <code>unwrap</code> with the same argument should succeed.
*
* @param iface a Class defining an interface.
* @return true if this implements the interface or directly or indirectly wraps an object that does.
* @throws java.sql.SQLException if an error occurs while determining whether this is a wrapper
* for an object with the given interface.
* @since 1.6
*/
boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException;
}