8187443: Forest Consolidation: Move files to unified layout

Reviewed-by: darcy, ihse
This commit is contained in:
Erik Joelsson 2017-09-12 19:03:39 +02:00
parent 270fe13182
commit 3789983e89
56923 changed files with 3 additions and 15727 deletions

View file

@ -0,0 +1,365 @@
/*
* Copyright (c) 1998, 2014, 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;
/**
* 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.
* <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.
*
* @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,563 @@
/*
* Copyright (c) 1998, 2014, 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.
*
* @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}.
*
* @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}.
*
* @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 Constructor 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
* possibility 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,306 @@
/*
* 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} value. An SQL {@code BLOB} 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} using
* an SQL {@code locator(BLOB)}, which means that a
* {@code Blob} object contains a logical pointer to the
* SQL {@code BLOB} data rather than the data itself.
* A {@code Blob} 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} and {@code setBlob} allow a programmer to
* access an SQL {@code BLOB} value.
* The {@code Blob} interface provides methods for getting the
* length of an SQL {@code BLOB} (Binary Large Object) value,
* for materializing a {@code BLOB} value on the client, and for
* determining the position of a pattern of bytes within a
* {@code BLOB} value. In addition, this interface has methods for updating
* a {@code BLOB} value.
* <p>
* All methods on the {@code Blob} 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} value
* designated by this {@code Blob} object.
*
* @return length of the {@code BLOB} in bytes
* @exception SQLException if there is an error accessing the
* length of the {@code BLOB}
* @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}
* value that this {@code Blob} object represents, as an array of
* bytes. This {@code byte} array contains up to {@code length}
* consecutive bytes starting at position {@code pos}.
*
* @param pos the ordinal position of the first byte in the
* {@code BLOB} 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}
* consecutive bytes from the {@code BLOB} value designated
* by this {@code Blob} object, starting with the
* byte at position {@code pos}
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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} value designated by this
* {@code Blob} instance as a stream.
*
* @return a stream containing the {@code BLOB} data
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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} begins within the {@code BLOB}
* value that this {@code Blob} object represents.
* The search for {@code pattern} begins at position
* {@code start}.
*
* @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} 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} value
* designated by this {@code Blob} object at which
* {@code pattern} begins. The search begins at position
* {@code start}.
*
* @param pattern the {@code Blob} object designating
* the {@code BLOB} value for which to search
* @param start the position in the {@code BLOB} 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} 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} value that
* this {@code Blob} object represents, starting at position
* {@code pos}, and returns the number of bytes written.
* The array of bytes will overwrite the existing bytes
* in the {@code Blob} object starting at the position
* {@code pos}. If the end of the {@code Blob} value is reached
* while writing the array of bytes, then the length of the {@code Blob}
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code BLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position in the {@code BLOB} object at which
* to start writing; the first position is 1
* @param bytes the array of bytes to be written to the {@code BLOB}
* value that this {@code Blob} object represents
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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} array to the
* {@code BLOB} value that this {@code Blob} object represents
* and returns the number of bytes written.
* Writing starts at position {@code pos} in the {@code BLOB}
* value; {@code len} bytes from the given byte array are written.
* The array of bytes will overwrite the existing bytes
* in the {@code Blob} object starting at the position
* {@code pos}. If the end of the {@code Blob} value is reached
* while writing the array of bytes, then the length of the {@code Blob}
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code BLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position in the {@code BLOB} object at which
* to start writing; the first position is 1
* @param bytes the array of bytes to be written to this {@code BLOB}
* object
* @param offset the offset into the array {@code bytes} at which
* to start reading the bytes to be set
* @param len the number of bytes to be written to the {@code BLOB}
* value from the array of bytes {@code bytes}
* @return the number of bytes written
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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}
* value that this {@code Blob} object represents. The stream begins
* at position {@code pos}.
* The bytes written to the stream will overwrite the existing bytes
* in the {@code Blob} object starting at the position
* {@code pos}. If the end of the {@code Blob} value is reached
* while writing to the stream, then the length of the {@code Blob}
* value will be increased to accommodate the extra bytes.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code BLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position in the {@code BLOB} value at which
* to start writing; the first position is 1
* @return a {@code java.io.OutputStream} object to which data can
* be written
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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} value that this {@code Blob}
* object represents to be {@code len} bytes in length.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code BLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param len the length, in bytes, to which the {@code BLOB} value
* that this {@code Blob} object represents should be truncated
* @exception SQLException if there is an error accessing the
* {@code BLOB} 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} object and releases the resources that
* it holds. The object is invalid once the {@code free}
* method is called.
* <p>
* After {@code free} has been called, any attempt to invoke a
* method other than {@code free} will result in an {@code SQLException}
* being thrown. If {@code free} is called multiple times, the subsequent
* calls to {@code free} are treated as a no-op.
*
* @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} object that contains
* a partial {@code Blob} 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} is at position 1.
* @param length the length in bytes of the partial value to be retrieved
* @return {@code InputStream} through which
* the partial {@code Blob} 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} or if
* pos + length is greater than the number of bytes
* in the {@code Blob}
*
* @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,353 @@
/*
* Copyright (c) 1998, 2014, 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} type.
* An SQL {@code CLOB} 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} object using an SQL
* {@code locator(CLOB)}, which means that a {@code Clob} object
* contains a logical pointer to the SQL {@code CLOB} data rather than
* the data itself. A {@code Clob} object is valid for the duration
* of the transaction in which it was created.
* <P>The {@code Clob} interface provides methods for getting the
* length of an SQL {@code CLOB} (Character Large Object) value,
* for materializing a {@code CLOB} value on the client, and for
* searching for a substring or {@code CLOB} object within a
* {@code CLOB} value.
* Methods in the interfaces {@link ResultSet},
* {@link CallableStatement}, and {@link PreparedStatement}, such as
* {@code getClob} and {@code setClob} allow a programmer to
* access an SQL {@code CLOB} value. In addition, this interface
* has methods for updating a {@code CLOB} value.
* <p>
* All methods on the {@code Clob} 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} value
* designated by this {@code Clob} object.
*
* @return length of the {@code CLOB} in characters
* @exception SQLException if there is an error accessing the
* length of the {@code CLOB} 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} value
* designated by this {@code Clob} object.
* The substring begins at position
* {@code pos} and has up to {@code length} 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} that is the specified substring in
* the {@code CLOB} value designated by this {@code Clob} object
* @exception SQLException if there is an error accessing the
* {@code CLOB} 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} value designated by this {@code Clob}
* object as a {@code java.io.Reader} object (or as a stream of
* characters).
*
* @return a {@code java.io.Reader} object containing the
* {@code CLOB} data
* @exception SQLException if there is an error accessing the
* {@code CLOB} 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} value designated by this {@code Clob}
* object as an ascii stream.
*
* @return a {@code java.io.InputStream} object containing the
* {@code CLOB} data
* @exception SQLException if there is an error accessing the
* {@code CLOB} 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} appears in the SQL {@code CLOB} value
* represented by this {@code Clob} object. The search
* begins at position {@code start}.
*
* @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} 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} object {@code searchstr} appears in this
* {@code Clob} object. The search begins at position
* {@code start}.
*
* @param searchstr the {@code Clob} 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} 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} 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} to the {@code CLOB}
* value that this {@code Clob} object designates at the position
* {@code pos}. The string will overwrite the existing characters
* in the {@code Clob} object starting at the position
* {@code pos}. If the end of the {@code Clob} value is reached
* while writing the given string, then the length of the {@code Clob}
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code CLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to the {@code CLOB}
* value that this {@code Clob} object represents;
* the first position is 1.
* @param str the string to be written to the {@code CLOB}
* value that this {@code Clob} designates
* @return the number of characters written
* @exception SQLException if there is an error accessing the
* {@code CLOB} 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} characters of {@code str}, starting
* at character {@code offset}, to the {@code CLOB} value
* that this {@code Clob} represents.
* The string will overwrite the existing characters
* in the {@code Clob} object starting at the position
* {@code pos}. If the end of the {@code Clob} value is reached
* while writing the given string, then the length of the {@code Clob}
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code CLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to this
* {@code CLOB} object; The first position is 1
* @param str the string to be written to the {@code CLOB}
* value that this {@code Clob} object represents
* @param offset the offset into {@code str} 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} 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} value that this {@code Clob} object represents,
* starting at position {@code pos}. Characters written to the stream
* will overwrite the existing characters
* in the {@code Clob} object starting at the position
* {@code pos}. If the end of the {@code Clob} value is reached
* while writing characters to the stream, then the length of the {@code Clob}
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code CLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to this
* {@code CLOB} 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} 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} value that this {@code Clob} object
* represents, at position {@code pos}. Characters written to the stream
* will overwrite the existing characters
* in the {@code Clob} object starting at the position
* {@code pos}. If the end of the {@code Clob} value is reached
* while writing characters to the stream, then the length of the {@code Clob}
* value will be increased to accommodate the extra characters.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code CLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param pos the position at which to start writing to the
* {@code CLOB} 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} 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} value that this {@code Clob}
* designates to have a length of {@code len}
* characters.
* <p>
* <b>Note:</b> If the value specified for {@code pos}
* is greater than the length+1 of the {@code CLOB} value then the
* behavior is undefined. Some JDBC drivers may throw an
* {@code SQLException} while other drivers may support this
* operation.
*
* @param len the length, in characters, to which the {@code CLOB} value
* should be truncated
* @exception SQLException if there is an error accessing the
* {@code CLOB} 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 releases the resources that the {@code Clob} object
* holds. The object is invalid once the {@code free} method
* is called.
* <p>
* After {@code free} has been called, any attempt to invoke a
* method other than {@code free} will result in a {@code SQLException}
* being thrown. If {@code free} is called multiple times, the subsequent
* calls to {@code free} are treated as a no-op.
*
* @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} object that contains
* a partial {@code Clob} 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} through which
* the partial {@code Clob} 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};
* or if pos + length is greater than the number of
* characters in the {@code Clob}
*
* @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,101 @@
/*
* Copyright (c) 2015, 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;
/**
* A builder created from a {@code DataSource} object,
* used to establish a connection to the database that the
* {@code data source} object represents. The connection
* properties that were specified for the {@code data source} are used as the
* default values by the {@code ConnectionBuilder}.
* <p>The following example illustrates the use of {@code ConnectionBuilder}
* to create a {@link Connection}:
*
* <pre>{@code
* DataSource ds = new MyDataSource();
* ShardingKey superShardingKey = ds.createShardingKeyBuilder()
* .subkey("EASTERN_REGION", JDBCType.VARCHAR)
* .build();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
* .build();
* Connection con = ds.createConnectionBuilder()
* .user("rafa")
* .password("tennis")
* .setShardingKey(shardingKey)
* .setSuperShardingKey(superShardingKey)
* .build();
* }</pre>
*
* @since 9
*
*/
public interface ConnectionBuilder {
/**
* Specifies the username to be used when creating a connection
*
* @param username the database user on whose behalf the connection is being
* made
* @return the same {@code ConnectionBuilder} instance
*/
ConnectionBuilder user(String username);
/**
* Specifies the password to be used when creating a connection
*
* @param password the password to use for this connection. May be {@code null}
* @return the same {@code ConnectionBuilder} instance
*/
ConnectionBuilder password(String password);
/**
* Specifies a {@code shardingKey} to be used when creating a connection
*
* @param shardingKey the ShardingKey. May be {@code null}
* @return the same {@code ConnectionBuilder} instance
* @see ShardingKey
* @see ShardingKeyBuilder
*/
ConnectionBuilder shardingKey(ShardingKey shardingKey);
/**
* Specifies a {@code superShardingKey} to be used when creating a connection
*
* @param superShardingKey the SuperShardingKey. May be {@code null}
* @return the same {@code ConnectionBuilder} instance
* @see ShardingKey
* @see ShardingKeyBuilder
*/
ConnectionBuilder superShardingKey(ShardingKey superShardingKey);
/**
* Returns an instance of the object defined by this builder.
*
* @return The built object
* @throws java.sql.SQLException If an error occurs building the object
*/
Connection build() throws SQLException;
}

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>.
*
* @since 1.1
*/
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.
*
* @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.
*
* @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,322 @@
/*
* Copyright (c) 1996, 2016, 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;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaLangAccess;
/**
* <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.
*
* @since 1.1
*/
public class Date extends java.util.Date {
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
/**
* 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(since="1.2")
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) {
if (s == null) {
throw new java.lang.IllegalArgumentException();
}
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;
Date d = null;
int firstDash = s.indexOf('-');
int secondDash = s.indexOf('-', firstDash + 1);
int len = s.length();
if ((firstDash > 0) && (secondDash > 0) && (secondDash < len - 1)) {
if (firstDash == YEAR_LENGTH &&
(secondDash - firstDash > 1 && secondDash - firstDash <= MONTH_LENGTH + 1) &&
(len - secondDash > 1 && len - secondDash <= DAY_LENGTH + 1)) {
int year = Integer.parseInt(s, 0, firstDash, 10);
int month = Integer.parseInt(s, firstDash + 1, secondDash, 10);
int day = Integer.parseInt(s, secondDash + 1, len, 10);
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.
*
* @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[] = new char[10];
formatDecimalInt(year, buf, 0, 4);
buf[4] = '-';
Date.formatDecimalInt(month, buf, 5, 2);
buf[7] = '-';
Date.formatDecimalInt(day, buf, 8, 2);
return jla.newStringUnsafe(buf);
}
/**
* Formats an unsigned integer into a char array in decimal output format.
* Numbers will be zero-padded or truncated if the string representation
* of the integer is smaller than or exceeds len, respectively.
*
* Should consider moving this to Integer and expose it through
* JavaLangAccess similar to Integer::formatUnsignedInt
* @param val Value to convert
* @param buf Array containing converted value
* @param offset Starting pos in buf
* @param len length of output value
*/
static void formatDecimalInt(int val, char[] buf, int offset, int len) {
int charPos = offset + len;
do {
buf[--charPos] = (char)('0' + (val % 10));
val /= 10;
} while (charPos > offset);
}
// 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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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());
}
/**
* Creates a {@code LocalDate} instance using the year, month and day
* from this {@code Date} object.
* @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,182 @@
/*
* 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
* @since 1.1
*/
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,741 @@
/*
* Copyright (c) 1996, 2017, 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.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.ServiceLoader;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Stream;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
/**
* The basic service for managing a set of JDBC drivers.
* <p>
* <strong>NOTE:</strong> The {@link javax.sql.DataSource} interface, provides
* another way to connect to a data source.
* The use of a {@code DataSource} object is the preferred means of
* connecting to a data source.
* <P>
* As part of its initialization, the {@code DriverManager} class will
* attempt to load available JDBC drivers by using:
* <ul>
* <li>The {@code jdbc.drivers} system property which contains a
* colon separated list of fully qualified class names of JDBC drivers. Each
* driver is loaded using the {@linkplain ClassLoader#getSystemClassLoader
* system class loader}:
* <ul>
* <li>{@code jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver}
* </ul>
*
* <li>Service providers of the {@code java.sql.Driver} class, that are loaded
* via the {@linkplain ServiceLoader#load service-provider loading} mechanism.
*</ul>
*
* @implNote
* {@code DriverManager} initialization is done lazily and looks up service
* providers using the thread context class loader. The drivers loaded and
* available to an application will depend on the thread context class loader of
* the thread that triggers driver initialization by {@code DriverManager}.
*
* <P>When the method {@code getConnection} is called,
* the {@code DriverManager} will attempt to
* locate a suitable driver from amongst those loaded at
* initialization and those loaded explicitly using the same class loader
* as the current application.
*
* @see Driver
* @see Connection
* @since 1.1
*/
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();
// Used in ensureDriversInitialized() to synchronize driversInitialized
private final static Object lockForInitDrivers = new Object();
private static volatile boolean driversInitialized;
private static final String JDBC_DRIVERS_PROPERTY = "jdbc.drivers";
/* Prevent the DriverManager class from being instantiated. */
private DriverManager(){}
/**
* 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>
* If a security manager exists, its {@code checkPermission}
* method is first called with a {@code SQLPermission("setLog")}
* permission to check that the caller is allowed to call {@code setLogWriter}.
*
* @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} method denies permission to set 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 + "\")");
ensureDriversInitialized();
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 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 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, its {@code checkPermission}
* method is first called with a {@code SQLPermission("deregisterDriver")}
* permission to check that the caller is allowed to deregister a JDBC Driver.
* <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 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);
synchronized (lockForInitDrivers) {
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
* @see #drivers()
*/
@CallerSensitive
public static Enumeration<Driver> getDrivers() {
ensureDriversInitialized();
return Collections.enumeration(getDrivers(Reflection.getCallerClass()));
}
/**
* Retrieves a Stream with all of the currently loaded JDBC drivers
* to which the current caller has access.
*
* @return the stream of JDBC Drivers loaded by the caller's class loader
* @since 9
*/
@CallerSensitive
public static Stream<Driver> drivers() {
ensureDriversInitialized();
return getDrivers(Reflection.getCallerClass()).stream();
}
private static List<Driver> getDrivers(Class<?> callerClass) {
List<Driver> result = new ArrayList<>();
// 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.add(aDriver.driver);
} else {
println(" skipping: " + aDriver.getClass().getName());
}
}
return result;
}
/**
* 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>
* If a security manager exists, its {@code checkPermission}
* method is first called with a {@code SQLPermission("setLog")}
* permission to check that the caller is allowed to call {@code setLogStream}.
*
* @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} method denies permission to set the log stream.
* @see SecurityManager#checkPermission
* @see #getLogStream
*/
@Deprecated(since="1.2")
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(since="1.2")
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;
}
/*
* Load the initial JDBC drivers by checking the System property
* jdbc.drivers and then use the {@code ServiceLoader} mechanism
*/
private static void ensureDriversInitialized() {
if (driversInitialized) {
return;
}
synchronized (lockForInitDrivers) {
if (driversInitialized) {
return;
}
String drivers;
try {
drivers = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(JDBC_DRIVERS_PROPERTY);
}
});
} 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("")) {
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);
}
}
}
driversInitialized = true;
println("JDBC DriverManager initialized");
}
}
// 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;
if (callerCL == null) {
callerCL = Thread.currentThread().getContextClassLoader();
}
if (url == null) {
throw new SQLException("The url cannot be null", "08001");
}
println("DriverManager.getConnection(\"" + url + "\")");
ensureDriversInitialized();
// 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,86 @@
/*
* 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.
*
* @since 1.1
*/
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.
*
* @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,53 @@
/*
* 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 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 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,279 @@
/*
* 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>
*
* @since 1.1
*/
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,310 @@
/*
* 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.
*
* @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.
*
* @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.
*
* @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>
*
* @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.
*
* @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.
*
* @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.
*
* @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>
*
* @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.
*
* @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.
*
* @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.
*
* @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>
*
* @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.
*
* @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.
*
* @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.
*
* @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>
*
* @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>.
*
* @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.
*
* @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>
*
* @return Map list containing the client info properties that could
* not be set
*
* @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,171 @@
/*
* 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,377 @@
/*
* Copyright (c) 1996, 2014, 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>getMessage</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>
*
* @since 1.1
*/
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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,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 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,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} thrown when an instance where a retry
* of the same operation would fail unless the cause of the <code>SQLException</code>
* is corrected.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,165 @@
/*
* Copyright (c) 1999, 2017, 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 class="striped">
* <caption style="display:none">permission target name, what the permission allows, and associated risks</caption>
* <thead>
* <tr>
* <th scope="col">Permission Target Name</th>
* <th scope="col">What the Permission Allows</th>
* <th scope="col">Risks of Allowing this Permission</th>
* </tr>
* </thead>
*
* <tbody>
* <tr>
* <th scope="row">setLog</th>
* <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>
* <th scope="row">callAbort</th>
* <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>
* <th scope="row">setSyncFactory</th>
* <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>
* <th scope="row">setNetworkTimeout</th>
* <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>
* <th scope="row">deregisterDriver</th>
* <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>
* </tbody>
* </table>
*
* @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,174 @@
/*
* 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,171 @@
/*
* 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.
*
* @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.
*
* @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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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,218 @@
/*
* 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
* @since 1.1
*/
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.
*
* @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.
*
* @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.
*
* @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>.
*
* @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.
*
* @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.
*
* @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>.
*
* @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, 2014, 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 writable 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 writable
* 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 writable 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 writable 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 writable 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 writable 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;
}

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2015, 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 used to indicate that this object represents a Sharding Key. A
* {@code ShardingKey} instance is only guaranteed to be compatible with the
* data source instance that it was derived from. A {@code ShardingKey} is
* created using {@link ShardingKeyBuilder}.
* <p>
* The following example illustrates the use of {@link ShardingKeyBuilder} to
* create a {@code ShardingKey}:
* <pre>
* {@code
*
* DataSource ds = new MyDataSource();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("abc", JDBCType.VARCHAR)
* .subkey(94002, JDBCType.INTEGER)
* .build();
* }
* </pre>
* <p>
*
* A {@code ShardingKey} may also be used for specifying a
* {@code superShardingKey}. Databases that support composite Sharding may use a
* {@code superShardingKey} to specify a additional level of partitioning within
* the Shard.
* <p>
* The following example illustrates the use of {@link ShardingKeyBuilder} to
* create a {@code superShardingKey} for an eastern region with a
* {@code ShardingKey} specified for the Pittsburgh branch office:
* <pre>
* {@code
*
* DataSource ds = new MyDataSource();
* ShardingKey superShardingKey = ds.createShardingKeyBuilder()
* .subkey("EASTERN_REGION", JDBCType.VARCHAR)
* .build();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
* .build();
* Connection con = ds.createConnectionBuilder()
* .superShardingKey(superShardingKey)
* .shardingKey(shardingKey)
* .build();
* }
* </pre>
*
* @since 9
*/
public interface ShardingKey {
}

View file

@ -0,0 +1,68 @@
/*
* Copyright (c) 2015, 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;
/**
* A builder created from a {@code DataSource} or {@code XADataSource} object,
* used to create a {@link ShardingKey} with sub-keys of supported data types.
* Implementations must
* support JDBCType.VARCHAR and may also support additional data types.
* <p>
* The following example illustrates the use of {@code ShardingKeyBuilder} to
* create a {@link ShardingKey}:
* <pre>
* {@code
*
* DataSource ds = new MyDataSource();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("abc", JDBCType.VARCHAR)
* .subkey(94002, JDBCType.INTEGER)
* .build();
* }
* </pre>
*
* @since 9
*/
public interface ShardingKeyBuilder {
/**
* This method will be called to add a subkey into a Sharding Key object being
* built. The order in which subkey method is called is important as it
* indicates the order of placement of the subkey within the Sharding Key.
*
* @param subkey contains the object that needs to be part of shard sub key
* @param subkeyType sub-key data type of type java.sql.SQLType
* @return this builder object
*/
ShardingKeyBuilder subkey(Object subkey, SQLType subkeyType);
/**
* Returns an instance of the object defined by this builder.
*
* @return The built object
* @throws java.sql.SQLException If an error occurs building the object
*/
ShardingKey build() 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,287 @@
/*
* Copyright (c) 1996, 2016, 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;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaLangAccess;
/**
* <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.
*
* @since 1.1
*/
public class Time extends java.util.Date {
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
/**
* 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(since="1.2")
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) {
if (s == null) throw new java.lang.IllegalArgumentException();
int hour;
int minute;
int second;
int firstColon = s.indexOf(':');
int secondColon = s.indexOf(':', firstColon + 1);
int len = s.length();
if (firstColon > 0 && secondColon > 0 &&
secondColon < len - 1) {
hour = Integer.parseInt(s, 0, firstColon, 10);
minute = Integer.parseInt(s, firstColon + 1, secondColon, 10);
second = Integer.parseInt(s, secondColon + 1, len, 10);
} 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();
char[] buf = new char[8];
Date.formatDecimalInt(hour, buf, 0, 2);
buf[2] = ':';
Date.formatDecimalInt(minute, buf, 3, 2);
buf[5] = ':';
Date.formatDecimalInt(second, buf, 6, 2);
return jla.newStringUnsafe(buf);
}
// 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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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(since="1.2")
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}. The nanosecond field from {@code LocalTime} is
* not part of the newly created {@code Time} object.
*
* @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}. The
* nanosecond {@code LocalTime} field will be set to zero.
*
* @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,570 @@
/*
* Copyright (c) 1996, 2017, 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 jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaLangAccess;
/**
* <P>A thin wrapper around {@code java.util.Date} that allows
* the JDBC API to identify this as an SQL {@code TIMESTAMP} value.
* It adds the ability
* to hold the SQL {@code TIMESTAMP} 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 }, which is the number of characters in yyyy-mm-dd hh:mm:ss
* <li> {@code 20 + s }, which is the number
* of characters in the yyyy-mm-dd hh:mm:ss.[fff...] and {@code s} 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} and a
* separate nanoseconds value. Only integral seconds are stored in the
* {@code java.util.Date} component. The fractional seconds - the nanos - are
* separate. The {@code Timestamp.equals(Object)} method never returns
* {@code true} when passed an object
* that isn't an instance of {@code java.sql.Timestamp},
* because the nanos component of a date is unknown.
* As a result, the {@code Timestamp.equals(Object)}
* method is not symmetric with respect to the
* {@code java.util.Date.equals(Object)}
* method. Also, the {@code hashCode} method uses the underlying
* {@code java.util.Date}
* implementation and therefore does not include nanos in its computation.
* <P>
* Due to the differences between the {@code Timestamp} class
* and the {@code java.util.Date}
* class mentioned above, it is recommended that code not view
* {@code Timestamp} values generically as an instance of
* {@code java.util.Date}. The
* inheritance relationship between {@code Timestamp}
* and {@code java.util.Date} really
* denotes implementation inheritance, and not type inheritance.
*
* @since 1.1
*/
public class Timestamp extends java.util.Date {
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
/**
* Constructs a {@code Timestamp} 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)}
* @exception IllegalArgumentException if the nano argument is out of bounds
*/
@Deprecated(since="1.2")
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} 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} field of
* the {@code Timestamp} 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} object to represent a point in time that is
* {@code time} 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} 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} object in JDBC timestamp escape format to a
* {@code Timestamp} value.
*
* @param s timestamp in format {@code yyyy-[m]m-[d]d hh:mm:ss[.f...]}. The
* fractional seconds may be omitted. The leading zero for {@code mm}
* and {@code dd} may also be omitted.
*
* @return corresponding {@code Timestamp} value
* @exception java.lang.IllegalArgumentException if the given argument
* does not have the format {@code yyyy-[m]m-[d]d hh:mm:ss[.f...]}
*/
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;
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;
int secondColon;
int period;
String formatError = "Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]";
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) {
throw new java.lang.IllegalArgumentException(formatError);
}
// Parse the date
firstDash = s.indexOf('-');
secondDash = s.indexOf('-', firstDash+1);
// Parse the time
firstColon = s.indexOf(':', dividingSpace + 1);
secondColon = s.indexOf(':', firstColon + 1);
period = s.indexOf('.', secondColon + 1);
// Convert the date
boolean parsedDate = false;
if (firstDash > 0 && secondDash > 0 && secondDash < dividingSpace - 1) {
if (firstDash == YEAR_LENGTH &&
(secondDash - firstDash > 1 && secondDash - firstDash <= MONTH_LENGTH + 1) &&
(dividingSpace - secondDash > 1 && dividingSpace - secondDash <= DAY_LENGTH + 1)) {
year = Integer.parseInt(s, 0, firstDash, 10);
month = Integer.parseInt(s, firstDash + 1, secondDash, 10);
day = Integer.parseInt(s, secondDash + 1, dividingSpace, 10);
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
int len = s.length();
if (firstColon > 0 && secondColon > 0 && secondColon < len - 1) {
hour = Integer.parseInt(s, dividingSpace + 1, firstColon, 10);
minute = Integer.parseInt(s, firstColon + 1, secondColon, 10);
if (period > 0 && period < len - 1) {
second = Integer.parseInt(s, secondColon + 1, period, 10);
int nanoPrecision = len - (period + 1);
if (nanoPrecision > 9)
throw new java.lang.IllegalArgumentException(formatError);
if (!Character.isDigit(s.charAt(period + 1)))
throw new java.lang.IllegalArgumentException(formatError);
int tmpNanos = Integer.parseInt(s, period + 1, len, 10);
while (nanoPrecision < 9) {
tmpNanos *= 10;
nanoPrecision++;
}
a_nanos = tmpNanos;
} else if (period > 0) {
throw new java.lang.IllegalArgumentException(formatError);
} else {
second = Integer.parseInt(s, secondColon + 1, len, 10);
}
} 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},
* where {@code fffffffff} indicates nanoseconds.
*
* @return a {@code String} object in
* {@code yyyy-mm-dd hh:mm:ss.fffffffff} 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();
int trailingZeros = 0;
int tmpNanos = nanos;
if (tmpNanos == 0) {
trailingZeros = 8;
} else {
while (tmpNanos % 10 == 0) {
tmpNanos /= 10;
trailingZeros++;
}
}
// 8058429: To comply with current JCK tests, we need to deal with year
// being any number between 0 and 292278995
int count = 10000;
int yearSize = 4;
do {
if (year < count) {
break;
}
yearSize++;
count *= 10;
} while (count < 1000000000);
char[] buf = new char[25 + yearSize - trailingZeros];
Date.formatDecimalInt(year, buf, 0, yearSize);
buf[yearSize] = '-';
Date.formatDecimalInt(month, buf, yearSize + 1, 2);
buf[yearSize + 3] = '-';
Date.formatDecimalInt(day, buf, yearSize + 4, 2);
buf[yearSize + 6] = ' ';
Date.formatDecimalInt(hour, buf, yearSize + 7, 2);
buf[yearSize + 9] = ':';
Date.formatDecimalInt(minute, buf, yearSize + 10, 2);
buf[yearSize + 12] = ':';
Date.formatDecimalInt(second, buf, yearSize + 13, 2);
buf[yearSize + 15] = '.';
Date.formatDecimalInt(tmpNanos, buf, yearSize + 16, 9 - trailingZeros);
return jla.newStringUnsafe(buf);
}
/**
* Gets this {@code Timestamp} object's {@code nanos} value.
*
* @return this {@code Timestamp} object's fractional seconds component
* @see #setNanos
*/
public int getNanos() {
return nanos;
}
/**
* Sets this {@code Timestamp} object's {@code nanos} 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} object is
* equal to the given {@code Timestamp} object.
*
* @param ts the {@code Timestamp} value to compare with
* @return {@code true} if the given {@code Timestamp}
* object is equal to this {@code Timestamp} object;
* {@code false} 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} object is
* equal to the given object.
*
* This version of the method {@code equals} has been added
* to fix the incorrect
* signature of {@code Timestamp.equals(Timestamp)} and to preserve backward
* compatibility with existing class files.
*
* Note: This method is not symmetric with respect to the
* {@code equals(Object)} method in the base class.
*
* @param ts the {@code Object} value to compare with
* @return {@code true} if the given {@code Object} is an instance
* of a {@code Timestamp} that
* is equal to this {@code Timestamp} object;
* {@code false} 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} object is
* earlier than the given {@code Timestamp} object.
*
* @param ts the {@code Timestamp} value to compare with
* @return {@code true} if this {@code Timestamp} object is earlier;
* {@code false} otherwise
*/
public boolean before(Timestamp ts) {
return compareTo(ts) < 0;
}
/**
* Indicates whether this {@code Timestamp} object is
* later than the given {@code Timestamp} object.
*
* @param ts the {@code Timestamp} value to compare with
* @return {@code true} if this {@code Timestamp} object is later;
* {@code false} otherwise
*/
public boolean after(Timestamp ts) {
return compareTo(ts) > 0;
}
/**
* Compares this {@code Timestamp} object to the given
* {@code Timestamp} object.
*
* @param ts the {@code Timestamp} object to be compared to
* this {@code Timestamp} object
* @return the value {@code 0} if the two {@code Timestamp}
* objects are equal; a value less than {@code 0} if this
* {@code Timestamp} object is before the given argument;
* and a value greater than {@code 0} if this
* {@code Timestamp} 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} object to the given
* {@code Date} object.
*
* @param o the {@code Date} to be compared to
* this {@code Timestamp} object
* @return the value {@code 0} if this {@code Timestamp} object
* and the given object are equal; a value less than {@code 0}
* if this {@code Timestamp} object is before the given argument;
* and a value greater than {@code 0} if this
* {@code Timestamp} 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 Timestamp}
* @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,344 @@
/*
* Copyright (c) 1996, 2014, 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.
*
* @since 1.1
*/
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, sometimes 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, sometimes 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;
}

View file

@ -0,0 +1,351 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 1998, 2017, 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.
-->
</head>
<body bgcolor="white">
Provides the API for accessing and processing data stored in a
data source (usually a relational database) using the
Java&trade; programming language.
This API includes a framework whereby different
drivers can be installed dynamically to access different data sources.
Although the JDBC&trade; API is mainly geared
to passing SQL statements to a database, it provides for reading and
writing data from any data source with a tabular format.
The reader/writer facility, available through the
<code>javax.sql.RowSet</code> group of interfaces, can be customized to
use and update data from a spread sheet, flat file, or any other tabular
data source.
<h2>What the JDBC&trade; 4.3 API Includes</h2>
The JDBC&trade; 4.3 API includes both
the <code>java.sql</code> package, referred to as the JDBC core API,
and the <code>javax.sql</code> package, referred to as the JDBC Optional
Package API. This complete JDBC API
is included in the Java&trade; Standard Edition (Java SE&trade;), version 7.
The <code>javax.sql</code> package extends the functionality of the JDBC API
from a client-side API to a server-side API, and it is an essential part
of the Java&trade; Enterprise Edition
(Java EE&trade;) technology.
<h2>Versions</h2>
The JDBC 4.3 API incorporates all of the previous JDBC API versions:
<UL>
<LI> The JDBC 4.2 API</li>
<LI> The JDBC 4.1 API</li>
<LI> The JDBC 4.0 API</li>
<LI> The JDBC 3.0 API</li>
<LI> The JDBC 2.1 core API</li>
<LI> The JDBC 2.0 Optional Package API<br>
(Note that the JDBC 2.1 core API and the JDBC 2.0 Optional Package
API together are referred to as the JDBC 2.0 API.)</li>
<LI> The JDBC 1.2 API</li>
<LI> The JDBC 1.0 API</li>
</UL>
<P>
Classes, interfaces, methods, fields, constructors, and exceptions
have the following "since" tags that indicate when they were introduced
into the Java platform. When these "since" tags are used in
Javadoc&trade; comments for the JDBC API,
they indicate the following:
<UL>
<LI>Since 9 -- new in the JDBC 4.3 API and part of the Java SE platform,
version 9</li>
<LI>Since 1.8 -- new in the JDBC 4.2 API and part of the Java SE platform,
version 8</li>
<LI>Since 1.7 -- new in the JDBC 4.1 API and part of the Java SE platform,
version 7</li>
<LI>Since 1.6 -- new in the JDBC 4.0 API and part of the Java SE platform,
version 6</li>
<LI>Since 1.4 -- new in the JDBC 3.0 API and part of the J2SE platform,
version 1.4</li>
<LI>Since 1.2 -- new in the JDBC 2.0 API and part of the J2SE platform,
version 1.2</li>
<LI>Since 1.1 or no "since" tag -- in the original JDBC 1.0 API and part of
the JDK&trade;, version 1.1</li>
</UL>
<P>
<b>NOTE:</b> Many of the new features are optional; consequently, there is
some variation in drivers and the features they support. Always
check your driver's documentation to see whether it supports a feature before
you try to use it.
<P>
<b>NOTE:</b> The class <code>SQLPermission</code> was added in the
Java&trade; 2 SDK, Standard Edition,
version 1.3 release. This class is used to prevent unauthorized
access to the logging stream associated with the <code>DriverManager</code>,
which may contain information such as table names, column data, and so on.
<h2>What the <code>java.sql</code> Package Contains</h2>
The <code>java.sql</code> package contains API for the following:
<UL>
<LI>Making a connection with a database via the <code>DriverManager</code> facility
<UL>
<LI><code>DriverManager</code> class -- makes a connection with a driver
<LI><code>SQLPermission</code> class -- provides permission when code
running within a Security Manager, such as an applet,
attempts to set up a logging stream through the
<code>DriverManager</code>
<LI><code>Driver</code> interface -- provides the API for registering
and connecting drivers based on JDBC technology ("JDBC drivers");
generally used only by the <code>DriverManager</code> class
<LI><code>DriverPropertyInfo</code> class -- provides properties for a
JDBC driver; not used by the general user
</UL>
<LI>Sending SQL statements to a database
<UL>
<LI><code>Statement</code> -- used to send basic SQL statements
<LI><code>PreparedStatement</code> -- used to send prepared statements or
basic SQL statements (derived from <code>Statement</code>)
<LI><code>CallableStatement</code> -- used to call database stored
procedures (derived from <code>PreparedStatement</code>)
<LI><code>Connection</code> interface -- provides methods for creating
statements and managing connections and their properties
<LI><code>Savepoint</code> -- provides savepoints in a transaction
</UL>
<LI>Retrieving and updating the results of a query
<UL>
<LI><code>ResultSet</code> interface
</UL>
<LI>Standard mappings for SQL types to classes and interfaces in the
Java programming language
<UL>
<LI><code>Array</code> interface -- mapping for SQL <code>ARRAY</code>
<LI><code>Blob</code> interface -- mapping for SQL <code>BLOB</code>
<LI><code>Clob</code> interface -- mapping for SQL <code>CLOB</code>
<LI><code>Date</code> class -- mapping for SQL <code>DATE</code>
<LI><code>NClob</code> interface -- mapping for SQL <code>NCLOB</code>
<LI><code>Ref</code> interface -- mapping for SQL <code>REF</code>
<LI><code>RowId</code> interface -- mapping for SQL <code>ROWID</code>
<LI><code>Struct</code> interface -- mapping for SQL <code>STRUCT</code>
<LI><code>SQLXML</code> interface -- mapping for SQL <code>XML</code>
<LI><code>Time</code> class -- mapping for SQL <code>TIME</code>
<LI><code>Timestamp</code> class -- mapping for SQL <code>TIMESTAMP</code>
<LI><code>Types</code> class -- provides constants for SQL types
</UL>
<LI>Custom mapping an SQL user-defined type (UDT) to a class in the
Java programming language
<UL>
<LI><code>SQLData</code> interface -- specifies the mapping of
a UDT to an instance of this class
<LI><code>SQLInput</code> interface -- provides methods for reading
UDT attributes from a stream
<LI><code>SQLOutput</code> interface -- provides methods for writing
UDT attributes back to a stream
</UL>
<LI>Metadata
<UL>
<LI><code>DatabaseMetaData</code> interface -- provides information
about the database
<LI><code>ResultSetMetaData</code> interface -- provides information
about the columns of a <code>ResultSet</code> object
<LI><code>ParameterMetaData</code> interface -- provides information
about the parameters to <code>PreparedStatement</code> commands
</UL>
<LI>Exceptions
<UL>
<LI><code>SQLException</code> -- thrown by most methods when there
is a problem accessing data and by some methods for other reasons
<LI><code>SQLWarning</code> -- thrown to indicate a warning
<LI><code>DataTruncation</code> -- thrown to indicate that data may have
been truncated
<LI><code>BatchUpdateException</code> -- thrown to indicate that not all
commands in a batch update executed successfully
</UL>
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.3 API</h3>
<UL>
<LI>Added <code>Sharding</code> support</LI>
<LI>Enhanced <code>Connection</code> to be able to provide hints
to the driver that a request, an independent unit of work,
is beginning or ending</LI>
<LI>Enhanced <code>DatabaseMetaData</code> to determine if Sharding is
supported</LI>
<LI>Added the method <code>drivers</code> to <code>DriverManager</code>
to return a Stream of the currently loaded and
available JDBC drivers</LI>
<LI>Added support to <code>Statement</code> for enquoting literals
and simple identifiers</LI>
<LI>Clarified the Java SE version that methods were deprecated</LI>
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.2 API</h3>
<UL>
<LI>Added <code>JDBCType</code> enum and <code>SQLType</code> interface</li>
<LI>Support for <code>REF CURSORS</code> in <code>CallableStatement</code>
</LI>
<LI><code>DatabaseMetaData</code> methods to return maximum Logical LOB size
and if Ref Cursors are supported</LI>
<LI>Added support for large update counts</LI>
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.1 API</h3>
<UL>
<LI>Allow <code>Connection</code>,
<code>ResultSet</code> and <code>Statement</code> objects to be
used with the try-with-resources statement</LI>
<LI>Support added to <code>CallableStatement</code> and
<code>ResultSet</code> to specify the Java type to convert to via the
<code>getObject</code> method</LI>
<LI><code>DatabaseMetaData</code> methods to return PseudoColumns and if a
generated key is always returned</LI>
<LI>Added support to <code>Connection</code> to specify a database schema,
abort and timeout a physical connection.</LI>
<LI>Added support to close a <code>Statement</code> object when its dependent
objects have been closed</LI>
<LI>Support for obtaining the parent logger for a <code>Driver</code>,
<code>DataSource</code>, <code>ConnectionPoolDataSource</code> and
<code>XADataSource</code></LI>
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 4.0 API</h3>
<UL>
<LI>auto java.sql.Driver discovery -- no longer need to load a
<code>java.sql.Driver</code> class via <code>Class.forName</code>
<LI>National Character Set support added
<li>Support added for the SQL:2003 XML data type
<lI>SQLException enhancements -- Added support for cause chaining; New SQLExceptions
added for common SQLState class value codes
<li>Enhanced Blob/Clob functionality -- Support provided to create and free a Blob/Clob instance
as well as additional methods added to improve accessibility
<li>Support added for accessing a SQL ROWID
<li>Support added to allow a JDBC application to access an instance of a JDBC resource
that has been wrapped by a vendor, usually in an application server or connection
pooling environment.
<li>Availability to be notified when a <code>PreparedStatement</code> that is associated
with a <code>PooledConnection</code> has been closed or the driver determines is invalid
</UL>
<h3><code>java.sql</code> and <code>javax.sql</code> Features Introduced in the JDBC 3.0 API</h3>
<UL>
<LI>Pooled statements -- reuse of statements associated with a pooled
connection
<LI>Savepoints -- allow a transaction to be rolled back to a designated
savepoint
<LI>Properties defined for <code>ConnectionPoolDataSource</code> -- specify
how connections are to be pooled
<LI>Metadata for parameters of a <code>PreparedStatement</code> object
<LI>Ability to retrieve values from automatically generated columns
<LI>Ability to have multiple <code>ResultSet</code> objects
returned from <code>CallableStatement</code> objects open at the
same time
<LI>Ability to identify parameters to <code>CallableStatement</code>
objects by name as well as by index
<LI><code>ResultSet</code> holdability -- ability to specify whether cursors
should be held open or closed at the end of a transaction
<LI>Ability to retrieve and update the SQL structured type instance that a
<code>Ref</code> object references
<LI>Ability to programmatically update <code>BLOB</code>,
<code>CLOB</code>, <code>ARRAY</code>, and <code>REF</code> values.
<LI>Addition of the <code>java.sql.Types.DATALINK</code> data type --
allows JDBC drivers access to objects stored outside a data source
<LI>Addition of metadata for retrieving SQL type hierarchies
</UL>
<h3><code>java.sql</code> Features Introduced in the JDBC 2.1 Core API</h3>
<UL>
<LI>Scrollable result sets--using new methods in the <code>ResultSet</code>
interface that allow the cursor to be moved to a particular row or to a
position relative to its current position
<LI>Batch updates
<LI>Programmatic updates--using <code>ResultSet</code> updater methods
<LI>New data types--interfaces mapping the SQL3 data types
<LI>Custom mapping of user-defined types (UDTs)
<LI>Miscellaneous features, including performance hints, the use of character
streams, full precision for <code>java.math.BigDecimal</code> values,
additional security, and
support for time zones in date, time, and timestamp values.
</UL>
<h3><code>javax.sql</code> Features Introduced in the JDBC 2.0 Optional
Package API</h3>
<UL>
<LI>The <code>DataSource</code> interface as a means of making a connection. The
Java Naming and Directory Interface&trade;
(JNDI) is used for registering a <code>DataSource</code> object with a
naming service and also for retrieving it.
<LI>Pooled connections -- allowing connections to be used and reused
<LI>Distributed transactions -- allowing a transaction to span diverse
DBMS servers
<LI><code>RowSet</code> technology -- providing a convenient means of
handling and passing data
</UL>
<h3>Custom Mapping of UDTs</h3>
A user-defined type (UDT) defined in SQL can be mapped to a class in the Java
programming language. An SQL structured type or an SQL <code>DISTINCT</code>
type are the UDTs that may be custom mapped. The following three
steps set up a custom mapping:
<ol>
<li>Defining the SQL structured type or <code>DISTINCT</code> type in SQL
<li>Defining the class in the Java programming language to which the
SQL UDT will be mapped. This class must implement the
<code>SQLData</code> interface.
<li>Making an entry in a <code>Connection</code> object's type map
that contains two things:
<ul>
<li>the fully-qualified SQL name of the UDT
<li>the <code>Class</code> object for the class that implements the
<code>SQLData</code> interface
</ul>
</ol>
<p>
When these are in place for a UDT, calling the methods
<code>ResultSet.getObject</code> or <code>CallableStatement.getObject</code>
on that UDT will automatically retrieve the custom mapping for it. Also, the
<code>PreparedStatement.setObject</code> method will automatically map the
object back to its SQL type to store it in the data source.
<h2>Package Specification</h2>
<ul>
<li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
</ul>
<h2>Related Documentation</h2>
<ul>
<li><a href="http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html">
Lesson:JDBC Basics(The Javaxx Tutorials &gt; JDBC&trade; Database Access)</a>
<li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
<i>JDBC&trade; API Tutorial and Reference, Third Edition</i></a>
</ul>
</body>
</html>

View file

@ -0,0 +1,143 @@
/*
* Copyright (c) 2005, 2016, 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 javax.sql;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.ShardingKeyBuilder;
import java.util.logging.Logger;
/**
* Interface that defines the methods which are common between <code>DataSource</code>,
* <code>XADataSource</code> and <code>ConnectionPoolDataSource</code>.
*
* @since 1.6
*/
public interface CommonDataSource {
/**
* <p>Retrieves the log writer for this <code>DataSource</code>
* object.
*
* <p>The log writer is a character output stream to which all logging
* and tracing messages for this data source will be
* printed. This includes messages printed by the methods of this
* object, messages printed by methods of other objects manufactured
* by this object, and so on. Messages printed to a data source
* specific log writer are not printed to the log writer associated
* with the <code>java.sql.DriverManager</code> class. When a
* <code>DataSource</code> object is
* created, the log writer is initially null; in other words, the
* default is for logging to be disabled.
*
* @return the log writer for this data source or null if
* logging is disabled
* @exception java.sql.SQLException if a database access error occurs
* @see #setLogWriter
*/
java.io.PrintWriter getLogWriter() throws SQLException;
/**
* <p>Sets the log writer for this <code>DataSource</code>
* object to the given <code>java.io.PrintWriter</code> object.
*
* <p>The log writer is a character output stream to which all logging
* and tracing messages for this data source will be
* printed. This includes messages printed by the methods of this
* object, messages printed by methods of other objects manufactured
* by this object, and so on. Messages printed to a data source-
* specific log writer are not printed to the log writer associated
* with the <code>java.sql.DriverManager</code> class. When a
* <code>DataSource</code> object is created the log writer is
* initially null; in other words, the default is for logging to be
* disabled.
*
* @param out the new log writer; to disable logging, set to null
* @exception SQLException if a database access error occurs
* @see #getLogWriter
*/
void setLogWriter(java.io.PrintWriter out) throws SQLException;
/**
* <p>Sets the maximum time in seconds that this data source will wait
* while attempting to connect to a database. A value of zero
* specifies that the timeout is the default system timeout
* if there is one; otherwise, it specifies that there is no timeout.
* When a <code>DataSource</code> object is created, the login timeout is
* initially zero.
*
* @param seconds the data source login time limit
* @exception SQLException if a database access error occurs.
* @see #getLoginTimeout
*/
void setLoginTimeout(int seconds) throws SQLException;
/**
* Gets the maximum time in seconds that this data source can wait
* while attempting to connect to a database. A value of zero
* means that the timeout is the default system timeout
* if there is one; otherwise, it means that there is no timeout.
* When a <code>DataSource</code> object is created, the login timeout is
* initially zero.
*
* @return the data source login time limit
* @exception SQLException if a database access error occurs.
* @see #setLoginTimeout
*/
int getLoginTimeout() throws SQLException;
//------------------------- JDBC 4.1 -----------------------------------
/**
* Return the parent Logger of all the Loggers used by this data source. This
* should be the Logger farthest from the root Logger that is
* still an ancestor of all of the Loggers used by this data source. Configuring
* this Logger will affect all of the log messages generated by the data source.
* In the worst case, this may be the root Logger.
*
* @return the parent Logger for this data source
* @throws SQLFeatureNotSupportedException if the data source does not use
* {@code java.util.logging}
* @since 1.7
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException;
//------------------------- JDBC 4.3 -----------------------------------
/**
* Creates a new {@code ShardingKeyBuilder} instance
* @implSpec
* The default implementation will throw a {@code SQLFeatureNotSupportedException}.
* @return The ShardingKeyBuilder instance that was created
* @throws SQLException if an error occurs creating the builder
* @throws SQLFeatureNotSupportedException if the driver does not support this method
* @since 9
* @see ShardingKeyBuilder
*/
default ShardingKeyBuilder createShardingKeyBuilder() throws SQLException {
throw new SQLFeatureNotSupportedException("createShardingKeyBuilder not implemented");
};
}

View file

@ -0,0 +1,95 @@
/*
* 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 javax.sql;
import java.sql.SQLException;
/**
* <P>An <code>Event</code> object that provides information about the
* source of a connection-related event. <code>ConnectionEvent</code>
* objects are generated when an application closes a pooled connection
* and when an error occurs. The <code>ConnectionEvent</code> object
* contains two kinds of information:
* <UL>
* <LI>The pooled connection closed by the application
* <LI>In the case of an error event, the <code>SQLException</code>
* about to be thrown to the application
* </UL>
*
* @since 1.4
*/
public class ConnectionEvent extends java.util.EventObject {
/**
* <P>Constructs a <code>ConnectionEvent</code> object initialized with
* the given <code>PooledConnection</code> object. <code>SQLException</code>
* defaults to <code>null</code>.
*
* @param con the pooled connection that is the source of the event
* @throws IllegalArgumentException if <code>con</code> is null.
*/
public ConnectionEvent(PooledConnection con) {
super(con);
}
/**
* <P>Constructs a <code>ConnectionEvent</code> object initialized with
* the given <code>PooledConnection</code> object and
* <code>SQLException</code> object.
*
* @param con the pooled connection that is the source of the event
* @param ex the SQLException about to be thrown to the application
* @throws IllegalArgumentException if <code>con</code> is null.
*/
public ConnectionEvent(PooledConnection con, SQLException ex) {
super(con);
this.ex = ex;
}
/**
* <P>Retrieves the <code>SQLException</code> for this
* <code>ConnectionEvent</code> object. May be <code>null</code>.
*
* @return the SQLException about to be thrown or <code>null</code>
*/
public SQLException getSQLException() { return ex; }
/**
* The <code>SQLException</code> that the driver will throw to the
* application when an error occurs and the pooled connection is no
* longer usable.
* @serial
*/
private SQLException ex = null;
/**
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = -4843217645290030002L;
}

View file

@ -0,0 +1,76 @@
/*
* Copyright (c) 2000, 2001, 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 javax.sql;
/**
* <P>
* An object that registers to be notified of events generated by a
* <code>PooledConnection</code> object.
* <P>
* The <code>ConnectionEventListener</code> interface is implemented by a
* connection pooling component. A connection pooling component will
* usually be provided by a JDBC driver vendor or another system software
* vendor. A JDBC driver notifies a <code>ConnectionEventListener</code>
* object when an application is finished using a pooled connection with
* which the listener has registered. The notification
* occurs after the application calls the method <code>close</code> on
* its representation of a <code>PooledConnection</code> object. A
* <code>ConnectionEventListener</code> is also notified when a
* connection error occurs due to the fact that the <code>PooledConnection</code>
* is unfit for future use---the server has crashed, for example.
* The listener is notified by the JDBC driver just before the driver throws an
* <code>SQLException</code> to the application using the
* <code>PooledConnection</code> object.
*
* @since 1.4
*/
public interface ConnectionEventListener extends java.util.EventListener {
/**
* Notifies this <code>ConnectionEventListener</code> that
* the application has called the method <code>close</code> on its
* representation of a pooled connection.
*
* @param event an event object describing the source of
* the event
*/
void connectionClosed(ConnectionEvent event);
/**
* Notifies this <code>ConnectionEventListener</code> that
* a fatal error has occurred and the pooled connection can
* no longer be used. The driver makes this notification just
* before it throws the application the <code>SQLException</code>
* contained in the given <code>ConnectionEvent</code> object.
*
* @param event an event object describing the source of
* the event and containing the <code>SQLException</code> that the
* driver is about to throw
*/
void connectionErrorOccurred(ConnectionEvent event);
}

View file

@ -0,0 +1,118 @@
/*
* Copyright (c) 2000, 2016, 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 javax.sql;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
/**
* A factory for <code>PooledConnection</code>
* objects. An object that implements this interface will typically be
* registered with a naming service that is based on the
* Java&trade; Naming and Directory Interface
* (JNDI).
*
* @since 1.4
*/
public interface ConnectionPoolDataSource extends CommonDataSource {
/**
* Attempts to establish a physical database connection that can
* be used as a pooled connection.
*
* @return a <code>PooledConnection</code> object that is a physical
* connection to the database that this
* <code>ConnectionPoolDataSource</code> object represents
* @exception SQLException if a database access error occurs
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
PooledConnection getPooledConnection() throws SQLException;
/**
* Attempts to establish a physical database connection that can
* be used as a pooled connection.
*
* @param user the database user on whose behalf the connection is being made
* @param password the user's password
* @return a <code>PooledConnection</code> object that is a physical
* connection to the database that this
* <code>ConnectionPoolDataSource</code> object represents
* @exception SQLException if a database access error occurs
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
PooledConnection getPooledConnection(String user, String password)
throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
java.io.PrintWriter getLogWriter() throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLogWriter(java.io.PrintWriter out) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLoginTimeout(int seconds) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
int getLoginTimeout() throws SQLException;
//------------------------- JDBC 4.3 -----------------------------------
/**
* Creates a new {@code PooledConnectionBuilder} instance
* @implSpec
* The default implementation will throw a {@code SQLFeatureNotSupportedException}.
* @return The ConnectionBuilder instance that was created
* @throws SQLException if an error occurs creating the builder
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see PooledConnectionBuilder
*/
default PooledConnectionBuilder createPooledConnectionBuilder() throws SQLException {
throw new SQLFeatureNotSupportedException("createPooledConnectionBuilder not implemented");
};
}

View file

@ -0,0 +1,156 @@
/*
* Copyright (c) 2000, 2016, 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 javax.sql;
import java.sql.Connection;
import java.sql.ConnectionBuilder;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.Wrapper;
/**
* <p>A factory for connections to the physical data source that this
* {@code DataSource} object represents. An alternative to the
* {@code DriverManager} facility, a {@code DataSource} object
* is the preferred means of getting a connection. An object that implements
* the {@code DataSource} interface will typically be
* registered with a naming service based on the
* Java&trade; Naming and Directory (JNDI) API.
* <P>
* The {@code DataSource} interface is implemented by a driver vendor.
* There are three types of implementations:
* <OL>
* <LI>Basic implementation -- produces a standard {@code Connection}
* object
* <LI>Connection pooling implementation -- produces a {@code Connection}
* object that will automatically participate in connection pooling. This
* implementation works with a middle-tier connection pooling manager.
* <LI>Distributed transaction implementation -- produces a
* {@code Connection} object that may be used for distributed
* transactions and almost always participates in connection pooling.
* This implementation works with a middle-tier
* transaction manager and almost always with a connection
* pooling manager.
* </OL>
* <P>
* A {@code DataSource} object has properties that can be modified
* when necessary. For example, if the data source is moved to a different
* server, the property for the server can be changed. The benefit is that
* because the data source's properties can be changed, any code accessing
* that data source does not need to be changed.
* <P>
* A driver that is accessed via a {@code DataSource} object does not
* register itself with the {@code DriverManager}. Rather, a
* {@code DataSource} object is retrieved through a lookup operation
* and then used to create a {@code Connection} object. With a basic
* implementation, the connection obtained through a {@code DataSource}
* object is identical to a connection obtained through the
* {@code DriverManager} facility.
* <p>
* An implementation of {@code DataSource} must include a public no-arg
* constructor.
*
* @since 1.4
*/
public interface DataSource extends CommonDataSource, Wrapper {
/**
* <p>Attempts to establish a connection with the data source that
* this {@code DataSource} object represents.
*
* @return a connection to the data source
* @exception SQLException if a database access error occurs
* @throws java.sql.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
*/
Connection getConnection() throws SQLException;
/**
* <p>Attempts to establish a connection with the data source that
* this {@code DataSource} object represents.
*
* @param username the database user on whose behalf the connection is
* being made
* @param password the user's password
* @return a connection to the data source
* @exception SQLException if a database access error occurs
* @throws java.sql.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
* @since 1.4
*/
Connection getConnection(String username, String password)
throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
java.io.PrintWriter getLogWriter() throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLogWriter(java.io.PrintWriter out) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLoginTimeout(int seconds) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
int getLoginTimeout() throws SQLException;
// JDBC 4.3
/**
* Create a new {@code ConnectionBuilder} instance
* @implSpec
* The default implementation will throw a {@code SQLFeatureNotSupportedException}
* @return The ConnectionBuilder instance that was created
* @throws SQLException if an error occurs creating the builder
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see ConnectionBuilder
*/
default ConnectionBuilder createConnectionBuilder() throws SQLException {
throw new SQLFeatureNotSupportedException("createConnectionBuilder not implemented");
};
}

View file

@ -0,0 +1,187 @@
/*
* Copyright (c) 2000, 2017, 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 javax.sql;
import java.sql.Connection;
import java.sql.SQLException;
/**
* An object that provides hooks for connection pool management.
* A <code>PooledConnection</code> object
* represents a physical connection to a data source. The connection
* can be recycled rather than being closed when an application is
* finished with it, thus reducing the number of connections that
* need to be made.
* <P>
* An application programmer does not use the <code>PooledConnection</code>
* interface directly; rather, it is used by a middle tier infrastructure
* that manages the pooling of connections.
* <P>
* When an application calls the method <code>DataSource.getConnection</code>,
* it gets back a <code>Connection</code> object. If connection pooling is
* being done, that <code>Connection</code> object is actually a handle to
* a <code>PooledConnection</code> object, which is a physical connection.
* <P>
* The connection pool manager, typically the application server, maintains
* a pool of <code>PooledConnection</code> objects. If there is a
* <code>PooledConnection</code> object available in the pool, the
* connection pool manager returns a <code>Connection</code> object that
* is a handle to that physical connection.
* If no <code>PooledConnection</code> object is available, the
* connection pool manager calls the <code>ConnectionPoolDataSource</code>
* method <code>getPoolConnection</code> to create a new physical connection. The
* JDBC driver implementing <code>ConnectionPoolDataSource</code> creates a
* new <code>PooledConnection</code> object and returns a handle to it.
* <P>
* When an application closes a connection, it calls the <code>Connection</code>
* method <code>close</code>. When connection pooling is being done,
* the connection pool manager is notified because it has registered itself as
* a <code>ConnectionEventListener</code> object using the
* <code>ConnectionPool</code> method <code>addConnectionEventListener</code>.
* The connection pool manager deactivates the handle to
* the <code>PooledConnection</code> object and returns the
* <code>PooledConnection</code> object to the pool of connections so that
* it can be used again. Thus, when an application closes its connection,
* the underlying physical connection is recycled rather than being closed.
* <p>
* If the connection pool manager wraps or provides a proxy to the logical
* handle returned from a call to {@code PoolConnection.getConnection}, the pool
* manager must do one of the following when the connection pool manager
* closes or returns the {@code PooledConnection} to the pool in response to
* the application calling {@code Connection.close}:
* <ul>
* <li>call {@code endRequest} on the logical {@code Connection} handle
* <li>call {@code close} on the logical {@code Connection} handle
* </ul>
* <p>
* The physical connection is not closed until the connection pool manager
* calls the <code>PooledConnection</code> method <code>close</code>.
* This method is generally called to have an orderly shutdown of the server or
* if a fatal error has made the connection unusable.
*
* <p>
* A connection pool manager is often also a statement pool manager, maintaining
* a pool of <code>PreparedStatement</code> objects.
* When an application closes a prepared statement, it calls the
* <code>PreparedStatement</code>
* method <code>close</code>. When <code>Statement</code> pooling is being done,
* the pool manager is notified because it has registered itself as
* a <code>StatementEventListener</code> object using the
* <code>ConnectionPool</code> method <code>addStatementEventListener</code>.
* Thus, when an application closes its <code>PreparedStatement</code>,
* the underlying prepared statement is recycled rather than being closed.
*
* @since 1.4
*/
public interface PooledConnection {
/**
* Creates and returns a <code>Connection</code> object that is a handle
* for the physical connection that
* this <code>PooledConnection</code> object represents.
* The connection pool manager calls this method when an application has
* called the method <code>DataSource.getConnection</code> and there are
* no <code>PooledConnection</code> objects available. See the
* {@link PooledConnection interface description} for more information.
*
* @return a <code>Connection</code> object that is a handle to
* this <code>PooledConnection</code> object
* @exception SQLException if a database access error occurs
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
Connection getConnection() throws SQLException;
/**
* Closes the physical connection that this <code>PooledConnection</code>
* object represents. An application never calls this method directly;
* it is called by the connection pool module, or manager.
* <P>
* See the {@link PooledConnection interface description} for more
* information.
*
* @exception SQLException if a database access error occurs
* @exception java.sql.SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @since 1.4
*/
void close() throws SQLException;
/**
* Registers the given event listener so that it will be notified
* when an event occurs on this <code>PooledConnection</code> object.
*
* @param listener a component, usually the connection pool manager,
* that has implemented the
* <code>ConnectionEventListener</code> interface and wants to be
* notified when the connection is closed or has an error
* @see #removeConnectionEventListener
*/
void addConnectionEventListener(ConnectionEventListener listener);
/**
* Removes the given event listener from the list of components that
* will be notified when an event occurs on this
* <code>PooledConnection</code> object.
*
* @param listener a component, usually the connection pool manager,
* that has implemented the
* <code>ConnectionEventListener</code> interface and
* been registered with this <code>PooledConnection</code> object as
* a listener
* @see #addConnectionEventListener
*/
void removeConnectionEventListener(ConnectionEventListener listener);
/**
* Registers a <code>StatementEventListener</code> with this <code>PooledConnection</code> object. Components that
* wish to be notified when <code>PreparedStatement</code>s created by the
* connection are closed or are detected to be invalid may use this method
* to register a <code>StatementEventListener</code> with this <code>PooledConnection</code> object.
*
* @param listener an component which implements the <code>StatementEventListener</code>
* interface that is to be registered with this <code>PooledConnection</code> object
*
* @since 1.6
*/
public void addStatementEventListener(StatementEventListener listener);
/**
* Removes the specified <code>StatementEventListener</code> from the list of
* components that will be notified when the driver detects that a
* <code>PreparedStatement</code> has been closed or is invalid.
*
* @param listener the component which implements the
* <code>StatementEventListener</code> interface that was previously
* registered with this <code>PooledConnection</code> object
*
* @since 1.6
*/
public void removeStatementEventListener(StatementEventListener listener);
}

View file

@ -0,0 +1,105 @@
/*
* Copyright (c) 2016, 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 javax.sql;
import java.sql.SQLException;
import java.sql.ShardingKey;
/**
* A builder created from a {@code ConnectionPoolDataSource} object,
* used to establish a connection to the database that the
* {@code data source} object represents. The connection
* properties that were specified for the {@code data source} are used as the
* default values by the {@code PooledConnectionBuilder}.
* <p>The following example illustrates the use of {@code PooledConnectionBuilder}
* to create a {@link XAConnection}:
*
* <pre>{@code
* ConnectionPoolDataSource ds = new MyConnectionPoolDataSource();
* ShardingKey superShardingKey = ds.createShardingKeyBuilder()
* .subkey("EASTERN_REGION", JDBCType.VARCHAR)
* .build();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
* .build();
* PooledConnection con = ds.createPooledConnectionBuilder()
* .user("rafa")
* .password("tennis")
* .setShardingKey(shardingKey)
* .setSuperShardingKey(superShardingKey)
* .build();
* }</pre>
*
* @since 9
*
*/
public interface PooledConnectionBuilder {
/**
* Specifies the username to be used when creating a connection
*
* @param username the database user on whose behalf the connection is being
* made
* @return the same {@code PooledConnectionBuilder} instance
*/
PooledConnectionBuilder user(String username);
/**
* Specifies the password to be used when creating a connection
*
* @param password the password to use for this connection. May be {@code null}
* @return the same {@code PooledConnectionBuilder} instance
*/
PooledConnectionBuilder password(String password);
/**
* Specifies a {@code shardingKey} to be used when creating a connection
*
* @param shardingKey the ShardingKey. May be {@code null}
* @return the same {@code PooledConnectionBuilder} instance
* @see java.sql.ShardingKey
* @see java.sql.ShardingKeyBuilder
*/
PooledConnectionBuilder shardingKey(ShardingKey shardingKey);
/**
* Specifies a {@code superShardingKey} to be used when creating a connection
*
* @param superShardingKey the SuperShardingKey. May be {@code null}
* @return the same {@code PooledConnectionBuilder} instance
* @see java.sql.ShardingKey
* @see java.sql.ShardingKeyBuilder
*/
PooledConnectionBuilder superShardingKey(ShardingKey superShardingKey);
/**
* Returns an instance of the object defined by this builder.
*
* @return The built object
* @throws java.sql.SQLException If an error occurs building the object
*/
PooledConnection build() throws SQLException;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,62 @@
/*
* 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 javax.sql;
/**
* An <code>Event</code> object generated when an event occurs to a
* <code>RowSet</code> object. A <code>RowSetEvent</code> object is
* generated when a single row in a rowset is changed, the whole rowset
* is changed, or the rowset cursor moves.
* <P>
* When an event occurs on a <code>RowSet</code> object, one of the
* <code>RowSetListener</code> methods will be sent to all registered
* listeners to notify them of the event. An <code>Event</code> object
* is supplied to the <code>RowSetListener</code> method so that the
* listener can use it to find out which <code>RowSet</code> object is
* the source of the event.
*
* @since 1.4
*/
public class RowSetEvent extends java.util.EventObject {
/**
* Constructs a <code>RowSetEvent</code> object initialized with the
* given <code>RowSet</code> object.
*
* @param source the <code>RowSet</code> object whose data has changed or
* whose cursor has moved
* @throws IllegalArgumentException if <code>source</code> is null.
*/
public RowSetEvent(RowSet source)
{ super(source); }
/**
* Private serial version unique ID to ensure serialization
* compatibility.
*/
static final long serialVersionUID = -1875450876546332005L;
}

View file

@ -0,0 +1,103 @@
/*
* Copyright (c) 2000, 2001, 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 javax.sql;
import java.sql.*;
/**
* The interface that a <code>RowSet</code> object implements in order to
* present itself to a <code>RowSetReader</code> or <code>RowSetWriter</code>
* object. The <code>RowSetInternal</code> interface contains
* methods that let the reader or writer access and modify the internal
* state of the rowset.
*
* @since 1.4
*/
public interface RowSetInternal {
/**
* Retrieves the parameters that have been set for this
* <code>RowSet</code> object's command.
*
* @return an array of the current parameter values for this <code>RowSet</code>
* object's command
* @exception SQLException if a database access error occurs
*/
Object[] getParams() throws SQLException;
/**
* Retrieves the <code>Connection</code> object that was passed to this
* <code>RowSet</code> object.
*
* @return the <code>Connection</code> object passed to the rowset
* or <code>null</code> if none was passed
* @exception SQLException if a database access error occurs
*/
Connection getConnection() throws SQLException;
/**
* Sets the given <code>RowSetMetaData</code> object as the
* <code>RowSetMetaData</code> object for this <code>RowSet</code>
* object. The <code>RowSetReader</code> object associated with the rowset
* will use <code>RowSetMetaData</code> methods to set the values giving
* information about the rowset's columns.
*
* @param md the <code>RowSetMetaData</code> object that will be set with
* information about the rowset's columns
*
* @exception SQLException if a database access error occurs
*/
void setMetaData(RowSetMetaData md) throws SQLException;
/**
* Retrieves a <code>ResultSet</code> object containing the original
* value of this <code>RowSet</code> object.
* <P>
* The cursor is positioned before the first row in the result set.
* Only rows contained in the result set returned by the method
* <code>getOriginal</code> are said to have an original value.
*
* @return the original value of the rowset
* @exception SQLException if a database access error occurs
*/
public ResultSet getOriginal() throws SQLException;
/**
* Retrieves a <code>ResultSet</code> object containing the original value
* of the current row only. If the current row has no original value,
* an empty result set is returned. If there is no current row,
* an exception is thrown.
*
* @return the original value of the current row as a <code>ResultSet</code>
* object
* @exception SQLException if a database access error occurs or this method
* is called while the cursor is on the insert row, before the
* first row, or after the last row
*/
public ResultSet getOriginalRow() throws SQLException;
}

View file

@ -0,0 +1,77 @@
/*
* Copyright (c) 2000, 2001, 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 javax.sql;
/**
* An interface that must be implemented by a
* component that wants to be notified when a significant
* event happens in the life of a <code>RowSet</code> object.
* A component becomes a listener by being registered with a
* <code>RowSet</code> object via the method <code>RowSet.addRowSetListener</code>.
* How a registered component implements this interface determines what it does
* when it is notified of an event.
*
* @since 1.4
*/
public interface RowSetListener extends java.util.EventListener {
/**
* Notifies registered listeners that a <code>RowSet</code> object
* in the given <code>RowSetEvent</code> object has changed its entire contents.
* <P>
* The source of the event can be retrieved with the method
* <code>event.getSource</code>.
*
* @param event a <code>RowSetEvent</code> object that contains
* the <code>RowSet</code> object that is the source of the event
*/
void rowSetChanged(RowSetEvent event);
/**
* Notifies registered listeners that a <code>RowSet</code> object
* has had a change in one of its rows.
* <P>
* The source of the event can be retrieved with the method
* <code>event.getSource</code>.
*
* @param event a <code>RowSetEvent</code> object that contains
* the <code>RowSet</code> object that is the source of the event
*/
void rowChanged(RowSetEvent event);
/**
* Notifies registered listeners that a <code>RowSet</code> object's
* cursor has moved.
* <P>
* The source of the event can be retrieved with the method
* <code>event.getSource</code>.
*
* @param event a <code>RowSetEvent</code> object that contains
* the <code>RowSet</code> object that is the source of the event
*/
void cursorMoved(RowSetEvent event);
}

View file

@ -0,0 +1,235 @@
/*
* 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 javax.sql;
import java.sql.*;
/**
* An object that contains information about the columns in a
* <code>RowSet</code> object. This interface is
* an extension of the <code>ResultSetMetaData</code> interface with
* methods for setting the values in a <code>RowSetMetaData</code> object.
* When a <code>RowSetReader</code> object reads data into a <code>RowSet</code>
* object, it creates a <code>RowSetMetaData</code> object and initializes it
* using the methods in the <code>RowSetMetaData</code> interface. Then the
* reader passes the <code>RowSetMetaData</code> object to the rowset.
* <P>
* The methods in this interface are invoked internally when an application
* calls the method <code>RowSet.execute</code>; an application
* programmer would not use them directly.
*
* @since 1.4
*/
public interface RowSetMetaData extends ResultSetMetaData {
/**
* Sets the number of columns in the <code>RowSet</code> object to
* the given number.
*
* @param columnCount the number of columns in the <code>RowSet</code> object
* @exception SQLException if a database access error occurs
*/
void setColumnCount(int columnCount) throws SQLException;
/**
* Sets whether the designated column is automatically numbered,
* The default is for a <code>RowSet</code> object's
* columns not to be automatically numbered.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is automatically
* numbered; <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setAutoIncrement(int columnIndex, boolean property) throws SQLException;
/**
* Sets whether the designated column is case sensitive.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is case sensitive;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setCaseSensitive(int columnIndex, boolean property) throws SQLException;
/**
* Sets whether the designated column can be used in a where clause.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column can be used in a
* <code>WHERE</code> clause; <code>false</code> if it cannot
*
* @exception SQLException if a database access error occurs
*/
void setSearchable(int columnIndex, boolean property) throws SQLException;
/**
* Sets whether the designated column is a cash value.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is a cash value;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setCurrency(int columnIndex, boolean property) throws SQLException;
/**
* Sets whether the designated column's value can be set to
* <code>NULL</code>.
* The default is <code>ResultSetMetaData.columnNullableUnknown</code>
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property one of the following constants:
* <code>ResultSetMetaData.columnNoNulls</code>,
* <code>ResultSetMetaData.columnNullable</code>, or
* <code>ResultSetMetaData.columnNullableUnknown</code>
*
* @exception SQLException if a database access error occurs
*/
void setNullable(int columnIndex, int property) throws SQLException;
/**
* Sets whether the designated column is a signed number.
* The default is <code>false</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param property <code>true</code> if the column is a signed number;
* <code>false</code> if it is not
*
* @exception SQLException if a database access error occurs
*/
void setSigned(int columnIndex, boolean property) throws SQLException;
/**
* Sets the designated column's normal maximum width in chars to the
* given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param size the normal maximum number of characters for
* the designated column
*
* @exception SQLException if a database access error occurs
*/
void setColumnDisplaySize(int columnIndex, int size) throws SQLException;
/**
* Sets the suggested column title for use in printouts and
* displays, if any, to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param label the column title
* @exception SQLException if a database access error occurs
*/
void setColumnLabel(int columnIndex, String label) throws SQLException;
/**
* Sets the name of the designated column to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param columnName the designated column's name
* @exception SQLException if a database access error occurs
*/
void setColumnName(int columnIndex, String columnName) throws SQLException;
/**
* Sets the name of the designated column's table's schema, if any, to
* the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param schemaName the schema name
* @exception SQLException if a database access error occurs
*/
void setSchemaName(int columnIndex, String schemaName) throws SQLException;
/**
* Sets the designated column's number of decimal digits to the
* given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param precision the total number of decimal digits
* @exception SQLException if a database access error occurs
*/
void setPrecision(int columnIndex, int precision) throws SQLException;
/**
* Sets the designated column's number of digits to the
* right of the decimal point to the given <code>int</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param scale the number of digits to right of decimal point
* @exception SQLException if a database access error occurs
*/
void setScale(int columnIndex, int scale) throws SQLException;
/**
* Sets the designated column's table name, if any, to the given
* <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param tableName the column's table name
* @exception SQLException if a database access error occurs
*/
void setTableName(int columnIndex, String tableName) throws SQLException;
/**
* Sets the designated column's table's catalog name, if any, to the given
* <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param catalogName the column's catalog name
* @exception SQLException if a database access error occurs
*/
void setCatalogName(int columnIndex, String catalogName) throws SQLException;
/**
* Sets the designated column's SQL type to the one given.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param SQLType the column's SQL type
* @exception SQLException if a database access error occurs
* @see Types
*/
void setColumnType(int columnIndex, int SQLType) throws SQLException;
/**
* Sets the designated column's type name that is specific to the
* data source, if any, to the given <code>String</code>.
*
* @param columnIndex the first column is 1, the second is 2, ...
* @param typeName data source specific type name.
* @exception SQLException if a database access error occurs
*/
void setColumnTypeName(int columnIndex, String typeName) throws SQLException;
}

View file

@ -0,0 +1,73 @@
/*
* Copyright (c) 2000, 2001, 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 javax.sql;
import java.sql.*;
/**
* The facility that a disconnected <code>RowSet</code> object calls on
* to populate itself with rows of data. A reader (an object implementing the
* <code>RowSetReader</code> interface) may be registered with
* a <code>RowSet</code> object that supports the reader/writer paradigm.
* When the <code>RowSet</code> object's <code>execute</code> method is
* called, it in turn calls the reader's <code>readData</code> method.
*
* @since 1.4
*/
public interface RowSetReader {
/**
* Reads the new contents of the calling <code>RowSet</code> object.
* In order to call this method, a <code>RowSet</code>
* object must have implemented the <code>RowSetInternal</code> interface
* and registered this <code>RowSetReader</code> object as its reader.
* The <code>readData</code> method is invoked internally
* by the <code>RowSet.execute</code> method for rowsets that support the
* reader/writer paradigm.
*
* <P>The <code>readData</code> method adds rows to the caller.
* It can be implemented in a wide variety of ways and can even
* populate the caller with rows from a nonrelational data source.
* In general, a reader may invoke any of the rowset's methods,
* with one exception. Calling the method <code>execute</code> will
* cause an <code>SQLException</code> to be thrown
* because <code>execute</code> may not be called recursively. Also,
* when a reader invokes <code>RowSet</code> methods, no listeners
* are notified; that is, no <code>RowSetEvent</code> objects are
* generated and no <code>RowSetListener</code> methods are invoked.
* This is true because listeners are already being notified by the method
* <code>execute</code>.
*
* @param caller the <code>RowSet</code> object (1) that has implemented the
* <code>RowSetInternal</code> interface, (2) with which this reader is
* registered, and (3) whose <code>execute</code> method called this reader
* @exception SQLException if a database access error occurs or this method
* invokes the <code>RowSet.execute</code> method
*/
void readData(RowSetInternal caller) throws SQLException;
}

View file

@ -0,0 +1,64 @@
/*
* Copyright (c) 2000, 2001, 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 javax.sql;
import java.sql.*;
/**
* An object that implements the <code>RowSetWriter</code> interface,
* called a <i>writer</i>. A writer may be registered with a <code>RowSet</code>
* object that supports the reader/writer paradigm.
* <P>
* If a disconnected <code>RowSet</code> object modifies some of its data,
* and it has a writer associated with it, it may be implemented so that it
* calls on the writer's <code>writeData</code> method internally
* to write the updates back to the data source. In order to do this, the writer
* must first establish a connection with the rowset's data source.
* <P>
* If the data to be updated has already been changed in the data source, there
* is a conflict, in which case the writer will not write
* the changes to the data source. The algorithm the writer uses for preventing
* or limiting conflicts depends entirely on its implementation.
*
* @since 1.4
*/
public interface RowSetWriter {
/**
* Writes the changes in this <code>RowSetWriter</code> object's
* rowset back to the data source from which it got its data.
*
* @param caller the <code>RowSet</code> object (1) that has implemented the
* <code>RowSetInternal</code> interface, (2) with which this writer is
* registered, and (3) that called this method internally
* @return <code>true</code> if the modified data was written; <code>false</code>
* if not, which will be the case if there is a conflict
* @exception SQLException if a database access error occurs
*/
boolean writeData(RowSetInternal caller) throws SQLException;
}

View file

@ -0,0 +1,118 @@
/*
* Copyright (c) 2005, 2014, 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.
*/
/*
* Created on Apr 28, 2005
*/
package javax.sql;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.EventObject;
/**
* A <code>StatementEvent</code> is sent to all <code>StatementEventListener</code>s which were
* registered with a <code>PooledConnection</code>. This occurs when the driver determines that a
* <code>PreparedStatement</code> that is associated with the <code>PooledConnection</code> has been closed or the driver determines
* is invalid.
*
* @since 1.6
*/
public class StatementEvent extends EventObject {
static final long serialVersionUID = -8089573731826608315L;
private SQLException exception;
private PreparedStatement statement;
/**
* Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code> and
* <code>PreparedStatement</code>. The <code>SQLException</code> contained in the event defaults to
* null.
*
* @param con The <code>PooledConnection</code> that the closed or invalid
* <code>PreparedStatement</code>is associated with.
* @param statement The <code>PreparedStatement</code> that is being closed or is invalid
*
* @throws IllegalArgumentException if <code>con</code> is null.
*
* @since 1.6
*/
public StatementEvent(PooledConnection con,
PreparedStatement statement) {
super(con);
this.statement = statement;
this.exception = null;
}
/**
* Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code>,
* <code>PreparedStatement</code> and <code>SQLException</code>
*
* @param con The <code>PooledConnection</code> that the closed or invalid <code>PreparedStatement</code>
* is associated with.
* @param statement The <code>PreparedStatement</code> that is being closed or is invalid
* @param exception The <code>SQLException </code>the driver is about to throw to
* the application
*
* @throws IllegalArgumentException if <code>con</code> is null.
*
* @since 1.6
*/
public StatementEvent(PooledConnection con,
PreparedStatement statement,
SQLException exception) {
super(con);
this.statement = statement;
this.exception = exception;
}
/**
* Returns the <code>PreparedStatement</code> that is being closed or is invalid
*
* @return The <code>PreparedStatement</code> that is being closed or is invalid
*
* @since 1.6
*/
public PreparedStatement getStatement() {
return this.statement;
}
/**
* Returns the <code>SQLException</code> the driver is about to throw
*
* @return The <code>SQLException</code> the driver is about to throw
*
* @since 1.6
*/
public SQLException getSQLException() {
return this.exception;
}
}

View file

@ -0,0 +1,86 @@
/*
* Copyright (c) 2005, 2014, 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.
*/
/*
* Created on Apr 28, 2005
*/
package javax.sql;
/**
* An object that registers to be notified of events that occur on PreparedStatements
* that are in the Statement pool.
* <p>
* The JDBC 3.0 specification added the maxStatements
* <code>ConnectionPooledDataSource</code> property to provide a standard mechanism for
* enabling the pooling of <code>PreparedStatements</code>
* and to specify the size of the statement
* pool. However, there was no way for a driver to notify an external
* statement pool when a <code>PreparedStatement</code> becomes invalid. For some databases, a
* statement becomes invalid if a DDL operation is performed that affects the
* table. For example an application may create a temporary table to do some work
* on the table and then destroy it. It may later recreate the same table when
* it is needed again. Some databases will invalidate any prepared statements
* that reference the temporary table when the table is dropped.
* <p>
* Similar to the methods defined in the <code>ConnectionEventListener</code> interface,
* the driver will call the <code>StatementEventListener.statementErrorOccurred</code>
* method prior to throwing any exceptions when it detects a statement is invalid.
* The driver will also call the <code>StatementEventListener.statementClosed</code>
* method when a <code>PreparedStatement</code> is closed.
* <p>
* Methods which allow a component to register a StatementEventListener with a
* <code>PooledConnection</code> have been added to the <code>PooledConnection</code> interface.
*
* @since 1.6
*/
public interface StatementEventListener extends java.util.EventListener{
/**
* The driver calls this method on all <code>StatementEventListener</code>s registered on the connection when it detects that a
* <code>PreparedStatement</code> is closed.
*
* @param event an event object describing the source of
* the event and that the <code>PreparedStatement</code> was closed.
* @since 1.6
*/
void statementClosed(StatementEvent event);
/**
* The driver calls this method on all <code>StatementEventListener</code>s
* registered on the connection when it detects that a
* <code>PreparedStatement</code> is invalid. The driver calls this method
* just before it throws the <code>SQLException</code>,
* contained in the given event, to the application.
*
* @param event an event object describing the source of the event,
* the statement that is invalid and the exception the
* driver is about to throw. The source of the event is
* the <code>PooledConnection</code> which the invalid <code>PreparedStatement</code>
* is associated with.
*
* @since 1.6
*/
void statementErrorOccurred(StatementEvent event);
}

View file

@ -0,0 +1,55 @@
/*
* Copyright (c) 2000, 2016, 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 javax.sql;
import java.sql.*;
/**
* An object that provides support for distributed transactions. An
* {@code XAConnection} object may be enlisted in a distributed transaction
* by means of an {@code XAResource} object. A transaction manager, usually
* part of a middle tier server, manages an {@code XAConnection} object
* through the {@code XAResource} object.
* <P>
* An application programmer does not use this interface directly; rather, it is
* used by a transaction manager working in the middle tier server.
*
* @since 1.4
*/
public interface XAConnection extends PooledConnection {
/**
* Retrieves an {@code XAResource} object that the transaction manager
* will use to manage this {@code XAConnection} object's participation
* in a distributed transaction.
*
* @return the {@code XAResource} object
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not
* support this method
* @since 1.4
*/
javax.transaction.xa.XAResource getXAResource() throws SQLException;
}

View file

@ -0,0 +1,105 @@
/*
* Copyright (c) 2016, 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 javax.sql;
import java.sql.SQLException;
import java.sql.ShardingKey;
/**
* A builder created from a {@code XADataSource} object,
* used to establish a connection to the database that the
* {@code data source} object represents. The connection
* properties that were specified for the {@code data source} are used as the
* default values by the {@code XAConnectionBuilder}.
* <p>The following example illustrates the use of {@code XAConnectionBuilder}
* to create a {@link XAConnection}:
*
* <pre>{@code
* XADataSource ds = new MyXADataSource();
* ShardingKey superShardingKey = ds.createShardingKeyBuilder()
* .subkey("EASTERN_REGION", JDBCType.VARCHAR)
* .build();
* ShardingKey shardingKey = ds.createShardingKeyBuilder()
* .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
* .build();
* XAConnection con = ds.createXAConnectionBuilder()
* .user("rafa")
* .password("tennis")
* .setShardingKey(shardingKey)
* .setSuperShardingKey(superShardingKey)
* .build();
* }</pre>
*
* @since 9
*
*/
public interface XAConnectionBuilder {
/**
* Specifies the username to be used when creating a connection
*
* @param username the database user on whose behalf the connection is being
* made
* @return the same {@code XAConnectionBuilder} instance
*/
XAConnectionBuilder user(String username);
/**
* Specifies the password to be used when creating a connection
*
* @param password the password to use for this connection. May be {@code null}
* @return the same {@code XAConnectionBuilder} instance
*/
XAConnectionBuilder password(String password);
/**
* Specifies a {@code shardingKey} to be used when creating a connection
*
* @param shardingKey the ShardingKey. May be {@code null}
* @return the same {@code XAConnectionBuilder} instance
* @see java.sql.ShardingKey
* @see java.sql.ShardingKeyBuilder
*/
XAConnectionBuilder shardingKey(ShardingKey shardingKey);
/**
* Specifies a {@code superShardingKey} to be used when creating a connection
*
* @param superShardingKey the SuperShardingKey. May be {@code null}
* @return the same {@code XAConnectionBuilder} instance
* @see java.sql.ShardingKey
* @see java.sql.ShardingKeyBuilder
*/
XAConnectionBuilder superShardingKey(ShardingKey superShardingKey);
/**
* Returns an instance of the object defined by this builder.
*
* @return The built object
* @throws java.sql.SQLException If an error occurs building the object
*/
XAConnection build() throws SQLException;
}

View file

@ -0,0 +1,128 @@
/*
* Copyright (c) 2000, 2016, 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 javax.sql;
import java.sql.*;
/**
* A factory for {@code XAConnection} objects that is used internally.
* An object that implements the {@code XADataSource} interface is
* typically registered with a naming service that uses the
* Java Naming and Directory Interface&trade;
* (JNDI).
* <p>
* An implementation of {@code XADataSource} must include a public no-arg
* constructor.
* @since 1.4
*/
public interface XADataSource extends CommonDataSource {
/**
* Attempts to establish a physical database connection that can be
* used in a distributed transaction.
*
* @return an {@code XAConnection} object, which represents a
* physical connection to a data source, that can be used in
* a distributed transaction
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @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
* @since 1.4
*/
XAConnection getXAConnection() throws SQLException;
/**
* Attempts to establish a physical database connection, using the given
* user name and password. The connection that is returned is one that
* can be used in a distributed transaction.
*
* @param user the database user on whose behalf the connection is being made
* @param password the user's password
* @return an {@code XAConnection} object, which represents a
* physical connection to a data source, that can be used in
* a distributed transaction
* @exception SQLException if a database access error occurs
* @exception SQLFeatureNotSupportedException if the JDBC driver does not support
* this method
* @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
* @since 1.4
*/
XAConnection getXAConnection(String user, String password)
throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
java.io.PrintWriter getLogWriter() throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLogWriter(java.io.PrintWriter out) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
void setLoginTimeout(int seconds) throws SQLException;
/**
* {@inheritDoc}
* @since 1.4
*/
@Override
int getLoginTimeout() throws SQLException;
// JDBC 4.3
/**
* Creates a new {@code XAConnectionBuilder} instance
* @implSpec
* The default implementation will throw a {@code SQLFeatureNotSupportedException}.
* @return The XAConnectionBuilder instance that was created
* @throws SQLException if an error occurs creating the builder
* @throws SQLFeatureNotSupportedException if the driver does not support sharding
* @since 9
* @see XAConnectionBuilder
*/
default XAConnectionBuilder createXAConnectionBuilder() throws SQLException {
throw new SQLFeatureNotSupportedException("createXAConnectionBuilder not implemented");
};
}

View file

@ -0,0 +1,302 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2000, 2017, 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.
-->
</head>
<body bgcolor="white">
Provides the API for server side data source access and processing from
the Java&trade; programming language.
This package supplements the <code>java.sql</code>
package and, as of the version 1.4 release, is included in the
Java Platform, Standard Edition (Java SE&trade;).
It remains an essential part of the Java Platform, Enterprise Edition
(Java EE&trade;).
<P>
The <code>javax.sql</code> package provides for the following:
<OL>
<LI>The <code>DataSource</code> interface as an alternative to the
<code>DriverManager</code> for establishing a
connection with a data source
<LI>Connection pooling and Statement pooling
<LI>Distributed transactions
<LI>Rowsets
</OL>
<P>
Applications use the <code>DataSource</code> and <code>RowSet</code>
APIs directly, but the connection pooling and distributed transaction
APIs are used internally by the middle-tier infrastructure.
<H2>Using a <code>DataSource</code> Object to Make a Connection</H2>
The <code>javax.sql</code> package provides the preferred
way to make a connection with a data source. The <code>DriverManager</code>
class, the original mechanism, is still valid, and code using it will
continue to run. However, the newer <code>DataSource</code> mechanism
is preferred because it offers many advantages over the
<code>DriverManager</code> mechanism.
<P>
These are the main advantages of using a <code>DataSource</code> object to
make a connection:
<UL>
<LI>Changes can be made to a data source's properties, which means
that it is not necessary to make changes in application code when
something about the data source or driver changes.
<LI>Connection and Statement pooling and distributed transactions are available
through a <code>DataSource</code> object that is
implemented to work with the middle-tier infrastructure.
Connections made through the <code>DriverManager</code>
do not have connection and statement pooling or distributed transaction
capabilities.
</UL>
<P>
Driver vendors provide <code>DataSource</code> implementations. A
particular <code>DataSource</code> object represents a particular
physical data source, and each connection the <code>DataSource</code> object
creates is a connection to that physical data source.
<P>
A logical name for the data source is registered with a naming service that
uses the Java Naming and Directory Interface&trade;
(JNDI) API, usually by a system administrator or someone performing the
duties of a system administrator. An application can retrieve the
<code>DataSource</code> object it wants by doing a lookup on the logical
name that has been registered for it. The application can then use the
<code>DataSource</code> object to create a connection to the physical data
source it represents.
<P>
A <code>DataSource</code> object can be implemented to work with the
middle tier infrastructure so that the connections it produces will be
pooled for reuse. An application that uses such a <code>DataSource</code>
implementation will automatically get a connection that participates in
connection pooling.
A <code>DataSource</code> object can also be implemented to work with the
middle tier infrastructure so that the connections it produces can be
used for distributed transactions without any special coding.
<H2>Connection Pooling and Statement Pooling</H2>
Connections made via a <code>DataSource</code>
object that is implemented to work with a middle tier connection pool manager
will participate in connection pooling. This can improve performance
dramatically because creating new connections is very expensive.
Connection pooling allows a connection to be used and reused,
thus cutting down substantially on the number of new connections
that need to be created.
<P>
Connection pooling is totally transparent. It is done automatically
in the middle tier of a Java EE configuration, so from an application's
viewpoint, no change in code is required. An application simply uses
the <code>DataSource.getConnection</code> method to get the pooled
connection and uses it the same way it uses any <code>Connection</code>
object.
<P>
The classes and interfaces used for connection pooling are:
<UL>
<LI><code>ConnectionPoolDataSource</code>
<LI><code>PooledConnection</code>
<LI><code>ConnectionEvent</code>
<LI><code>ConnectionEventListener</code>
<LI><code>StatementEvent</code>
<LI><code>StatementEventListener</code>
</UL>
The connection pool manager, a facility in the middle tier of
a three-tier architecture, uses these classes and interfaces
behind the scenes. When a <code>ConnectionPoolDataSource</code> object
is called on to create a <code>PooledConnection</code> object, the
connection pool manager will register as a <code>ConnectionEventListener</code>
object with the new <code>PooledConnection</code> object. When the connection
is closed or there is an error, the connection pool manager (being a listener)
gets a notification that includes a <code>ConnectionEvent</code> object.
<p>
If the connection pool manager supports <code>Statement</code> pooling, for
<code>PreparedStatements</code>, which can be determined by invoking the method
<code>DatabaseMetaData.supportsStatementPooling</code>, the
connection pool manager will register as a <code>StatementEventListener</code>
object with the new <code>PooledConnection</code> object. When the
<code>PreparedStatement</code> is closed or there is an error, the connection
pool manager (being a listener)
gets a notification that includes a <code>StatementEvent</code> object.
<H2>Distributed Transactions</H2>
As with pooled connections, connections made via a <code>DataSource</code>
object that is implemented to work with the middle tier infrastructure
may participate in distributed transactions. This gives an application
the ability to involve data sources on multiple servers in a single
transaction.
<P>
The classes and interfaces used for distributed transactions are:
<UL>
<LI><code>XADataSource</code>
<LI><code>XAConnection</code>
</UL>
These interfaces are used by the transaction manager; an application does
not use them directly.
<P>
The <code>XAConnection</code> interface is derived from the
<code>PooledConnection</code> interface, so what applies to a pooled connection
also applies to a connection that is part of a distributed transaction.
A transaction manager in the middle tier handles everything transparently.
The only change in application code is that an application cannot do anything
that would interfere with the transaction manager's handling of the transaction.
Specifically, an application cannot call the methods <code>Connection.commit</code>
or <code>Connection.rollback</code>, and it cannot set the connection to be in
auto-commit mode (that is, it cannot call
<code>Connection.setAutoCommit(true)</code>).
<P>
An application does not need to do anything special to participate in a
distributed transaction.
It simply creates connections to the data sources it wants to use via
the <code>DataSource.getConnection</code> method, just as it normally does.
The transaction manager manages the transaction behind the scenes. The
<code>XADataSource</code> interface creates <code>XAConnection</code> objects, and
each <code>XAConnection</code> object creates an <code>XAResource</code> object
that the transaction manager uses to manage the connection.
<H2>Rowsets</H2>
The <code>RowSet</code> interface works with various other classes and
interfaces behind the scenes. These can be grouped into three categories.
<OL>
<LI>Event Notification
<UL>
<LI><code>RowSetListener</code><br>
A <code>RowSet</code> object is a JavaBeans&trade;
component because it has properties and participates in the JavaBeans
event notification mechanism. The <code>RowSetListener</code> interface
is implemented by a component that wants to be notified about events that
occur to a particular <code>RowSet</code> object. Such a component registers
itself as a listener with a rowset via the <code>RowSet.addRowSetListener</code>
method.
<P>
When the <code>RowSet</code> object changes one of its rows, changes all of
it rows, or moves its cursor, it also notifies each listener that is registered
with it. The listener reacts by carrying out its implementation of the
notification method called on it.
<LI><code>RowSetEvent</code><br>
As part of its internal notification process, a <code>RowSet</code> object
creates an instance of <code>RowSetEvent</code> and passes it to the listener.
The listener can use this <code>RowSetEvent</code> object to find out which rowset
had the event.
</UL>
<LI>Metadata
<UL>
<LI><code>RowSetMetaData</code><br>
This interface, derived from the
<code>ResultSetMetaData</code> interface, provides information about
the columns in a <code>RowSet</code> object. An application can use
<code>RowSetMetaData</code> methods to find out how many columns the
rowset contains and what kind of data each column can contain.
<P>
The <code>RowSetMetaData</code> interface provides methods for
setting the information about columns, but an application would not
normally use these methods. When an application calls the <code>RowSet</code>
method <code>execute</code>, the <code>RowSet</code> object will contain
a new set of rows, and its <code>RowSetMetaData</code> object will have been
internally updated to contain information about the new columns.
</UL>
<LI>The Reader/Writer Facility<br>
A <code>RowSet</code> object that implements the <code>RowSetInternal</code>
interface can call on the <code>RowSetReader</code> object associated with it
to populate itself with data. It can also call on the <code>RowSetWriter</code>
object associated with it to write any changes to its rows back to the
data source from which it originally got the rows.
A rowset that remains connected to its data source does not need to use a
reader and writer because it can simply operate on the data source directly.
<UL>
<LI><code>RowSetInternal</code><br>
By implementing the <code>RowSetInternal</code> interface, a
<code>RowSet</code> object gets access to
its internal state and is able to call on its reader and writer. A rowset
keeps track of the values in its current rows and of the values that immediately
preceded the current ones, referred to as the <i>original</i> values. A rowset
also keeps track of (1) the parameters that have been set for its command and
(2) the connection that was passed to it, if any. A rowset uses the
<code>RowSetInternal</code> methods behind the scenes to get access to
this information. An application does not normally invoke these methods directly.
<LI><code>RowSetReader</code><br>
A disconnected <code>RowSet</code> object that has implemented the
<code>RowSetInternal</code> interface can call on its reader (the
<code>RowSetReader</code> object associated with it) to populate it with
data. When an application calls the <code>RowSet.execute</code> method,
that method calls on the rowset's reader to do much of the work. Implementations
can vary widely, but generally a reader makes a connection to the data source,
reads data from the data source and populates the rowset with it, and closes
the connection. A reader may also update the <code>RowSetMetaData</code> object
for its rowset. The rowset's internal state is also updated, either by the
reader or directly by the method <code>RowSet.execute</code>.
<LI><code>RowSetWriter</code><br>
A disconnected <code>RowSet</code> object that has implemented the
<code>RowSetInternal</code> interface can call on its writer (the
<code>RowSetWriter</code> object associated with it) to write changes
back to the underlying data source. Implementations may vary widely, but
generally, a writer will do the following:
<UL>
<LI>Make a connection to the data source
<LI>Check to see whether there is a conflict, that is, whether
a value that has been changed in the rowset has also been changed
in the data source
<LI>Write the new values to the data source if there is no conflict
<LI>Close the connection
</UL>
</UL>
</OL>
<P>
The <code>RowSet</code> interface may be implemented in any number of
ways, and anyone may write an implementation. Developers are encouraged
to use their imaginations in coming up with new ways to use rowsets.
<h2>Package Specification</h2>
<ul>
<li><a href="https://jcp.org/en/jsr/detail?id=221">JDBC 4.3 Specification</a>
</ul>
<h2>Related Documentation</h2>
The Java Series book published by Addison-Wesley Longman provides detailed
information about the classes and interfaces in the <code>javax.sql</code>
package:
<ul>
<li><a href="http://www.oracle.com/technetwork/java/index-142838.html">
<i>JDBC&#8482;API Tutorial and Reference, Third Edition</i></a>
</ul>
</body>
</html>

View file

@ -0,0 +1,201 @@
/*
* Copyright (c) 2000, 2001, 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 javax.transaction.xa;
/**
* The XAException is thrown by the Resource Manager (RM) to inform the
* Transaction Manager of an error encountered by the involved transaction.
*
* @since 1.4
*/
public class XAException extends Exception {
/**
* Specify serialVersionUID for backward compatibility
*/
private static final long serialVersionUID = -8249683284832867751L;
/**
* The error code with which to create the SystemException.
*
* @serial The error code for the exception
*/
public int errorCode;
/**
* Create an XAException.
*/
public XAException() {
super();
}
/**
* Create an XAException with a given string.
*
* @param s The <code>String</code> object containing the exception
* message.
*/
public XAException(String s) {
super(s);
}
/**
* Create an XAException with a given error code.
*
* @param errcode The error code identifying the exception.
*/
public XAException(int errcode) {
super();
errorCode = errcode;
}
/**
* The inclusive lower bound of the rollback codes.
*/
public final static int XA_RBBASE = 100;
/**
* Indicates that the rollback was caused by an unspecified reason.
*/
public final static int XA_RBROLLBACK = XA_RBBASE;
/**
* Indicates that the rollback was caused by a communication failure.
*/
public final static int XA_RBCOMMFAIL = XA_RBBASE + 1;
/**
* A deadlock was detected.
*/
public final static int XA_RBDEADLOCK = XA_RBBASE + 2;
/**
* A condition that violates the integrity of the resource was detected.
*/
public final static int XA_RBINTEGRITY = XA_RBBASE + 3;
/**
* The resource manager rolled back the transaction branch for a reason
* not on this list.
*/
public final static int XA_RBOTHER = XA_RBBASE + 4;
/**
* A protocol error occurred in the resource manager.
*/
public final static int XA_RBPROTO = XA_RBBASE + 5;
/**
* A transaction branch took too long.
*/
public final static int XA_RBTIMEOUT = XA_RBBASE + 6;
/**
* May retry the transaction branch.
*/
public final static int XA_RBTRANSIENT = XA_RBBASE + 7;
/**
* The inclusive upper bound of the rollback error code.
*/
public final static int XA_RBEND = XA_RBTRANSIENT;
/**
* Resumption must occur where the suspension occurred.
*/
public final static int XA_NOMIGRATE = 9;
/**
* The transaction branch may have been heuristically completed.
*/
public final static int XA_HEURHAZ = 8;
/**
* The transaction branch has been heuristically committed.
*/
public final static int XA_HEURCOM = 7;
/**
* The transaction branch has been heuristically rolled back.
*/
public final static int XA_HEURRB = 6;
/**
* The transaction branch has been heuristically committed and
* rolled back.
*/
public final static int XA_HEURMIX = 5;
/**
* Routine returned with no effect and may be reissued.
*/
public final static int XA_RETRY = 4;
/**
* The transaction branch was read-only and has been committed.
*/
public final static int XA_RDONLY = 3;
/**
* There is an asynchronous operation already outstanding.
*/
public final static int XAER_ASYNC = -2;
/**
* A resource manager error has occurred in the transaction branch.
*/
public final static int XAER_RMERR = -3;
/**
* The XID is not valid.
*/
public final static int XAER_NOTA = -4;
/**
* Invalid arguments were given.
*/
public final static int XAER_INVAL = -5;
/**
* Routine was invoked in an inproper context.
*/
public final static int XAER_PROTO = -6;
/**
* Resource manager is unavailable.
*/
public final static int XAER_RMFAIL = -7;
/**
* The XID already exists.
*/
public final static int XAER_DUPID = -8;
/**
* The resource manager is doing work outside a global transaction.
*/
public final static int XAER_OUTSIDE = -9;
}

View file

@ -0,0 +1,306 @@
/*
* Copyright (c) 2000, 2001, 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 javax.transaction.xa;
/**
* The XAResource interface is a Java mapping of the industry standard
* XA interface based on the X/Open CAE Specification (Distributed
* Transaction Processing: The XA Specification).
*
* <p>The XA interface defines the contract between a Resource Manager
* and a Transaction Manager in a distributed transaction processing
* (DTP) environment. A JDBC driver or a JMS provider implements
* this interface to support the association between a global transaction
* and a database or message service connection.
*
* <p>The XAResource interface can be supported by any transactional
* resource that is intended to be used by application programs in an
* environment where transactions are controlled by an external
* transaction manager. An example of such a resource is a database
* management system. An application may access data through multiple
* database connections. Each database connection is enlisted with
* the transaction manager as a transactional resource. The transaction
* manager obtains an XAResource for each connection participating
* in a global transaction. The transaction manager uses the
* <code>start</code> method
* to associate the global transaction with the resource, and it uses the
* <code>end</code> method to disassociate the transaction from
* the resource. The resource
* manager is responsible for associating the global transaction to all
* work performed on its data between the start and end method invocations.
*
* <p>At transaction commit time, the resource managers are informed by
* the transaction manager to prepare, commit, or rollback a transaction
* according to the two-phase commit protocol.</p>
*
* @since 1.4
*/
public interface XAResource {
/**
* Commits the global transaction specified by xid.
*
* @param xid A global transaction identifier
*
* @param onePhase If true, the resource manager should use a one-phase
* commit protocol to commit the work done on behalf of xid.
*
* @exception XAException An error has occurred. Possible XAExceptions
* are XA_HEURHAZ, XA_HEURCOM, XA_HEURRB, XA_HEURMIX, XAER_RMERR,
* XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or XAER_PROTO.
*
* <P>If the resource manager did not commit the transaction and the
* paramether onePhase is set to true, the resource manager may throw
* one of the XA_RB* exceptions. Upon return, the resource manager has
* rolled back the branch's work and has released all held resources.
*/
void commit(Xid xid, boolean onePhase) throws XAException;
/**
* Ends the work performed on behalf of a transaction branch.
* The resource manager disassociates the XA resource from the
* transaction branch specified and lets the transaction
* complete.
*
* <p>If TMSUSPEND is specified in the flags, the transaction branch
* is temporarily suspended in an incomplete state. The transaction
* context is in a suspended state and must be resumed via the
* <code>start</code> method with TMRESUME specified.</p>
*
* <p>If TMFAIL is specified, the portion of work has failed.
* The resource manager may mark the transaction as rollback-only</p>
*
* <p>If TMSUCCESS is specified, the portion of work has completed
* successfully.</p>
*
* @param xid A global transaction identifier that is the same as
* the identifier used previously in the <code>start</code> method.
*
* @param flags One of TMSUCCESS, TMFAIL, or TMSUSPEND.
*
* @exception XAException An error has occurred. Possible XAException
* values are XAER_RMERR, XAER_RMFAILED, XAER_NOTA, XAER_INVAL,
* XAER_PROTO, or XA_RB*.
*/
void end(Xid xid, int flags) throws XAException;
/**
* Tells the resource manager to forget about a heuristically
* completed transaction branch.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL, or
* XAER_PROTO.
*/
void forget(Xid xid) throws XAException;
/**
* Obtains the current transaction timeout value set for this
* XAResource instance. If <CODE>XAResource.setTransactionTimeout</CODE>
* was not used prior to invoking this method, the return value
* is the default timeout set for the resource manager; otherwise,
* the value used in the previous <CODE>setTransactionTimeout</CODE>
* call is returned.
*
* @return the transaction timeout value in seconds.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR and XAER_RMFAIL.
*/
int getTransactionTimeout() throws XAException;
/**
* This method is called to determine if the resource manager
* instance represented by the target object is the same as the
* resouce manager instance represented by the parameter <i>xares</i>.
*
* @param xares An XAResource object whose resource manager instance
* is to be compared with the resource manager instance of the
* target object.
*
* @return <i>true</i> if it's the same RM instance; otherwise
* <i>false</i>.
*
* @exception XAException An error has occurred. Possible exception
* values are XAER_RMERR and XAER_RMFAIL.
*/
boolean isSameRM(XAResource xares) throws XAException;
/**
* Ask the resource manager to prepare for a transaction commit
* of the transaction specified in xid.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred. Possible exception
* values are: XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_NOTA, XAER_INVAL,
* or XAER_PROTO.
*
* @return A value indicating the resource manager's vote on the
* outcome of the transaction. The possible values are: XA_RDONLY
* or XA_OK. If the resource manager wants to roll back the
* transaction, it should do so by raising an appropriate XAException
* in the prepare method.
*/
int prepare(Xid xid) throws XAException;
/**
* Obtains a list of prepared transaction branches from a resource
* manager. The transaction manager calls this method during recovery
* to obtain the list of transaction branches that are currently in
* prepared or heuristically completed states.
*
* @param flag One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS
* must be used when no other flags are set in the parameter.
*
* @exception XAException An error has occurred. Possible values are
* XAER_RMERR, XAER_RMFAIL, XAER_INVAL, and XAER_PROTO.
*
* @return The resource manager returns zero or more XIDs of the
* transaction branches that are currently in a prepared or
* heuristically completed state. If an error occurs during the
* operation, the resource manager should throw the appropriate
* XAException.
*/
Xid[] recover(int flag) throws XAException;
/**
* Informs the resource manager to roll back work done on behalf
* of a transaction branch.
*
* @param xid A global transaction identifier.
*
* @exception XAException An error has occurred.
*/
void rollback(Xid xid) throws XAException;
/**
* Sets the current transaction timeout value for this <CODE>XAResource</CODE>
* instance. Once set, this timeout value is effective until
* <code>setTransactionTimeout</code> is invoked again with a different
* value. To reset the timeout value to the default value used by the resource
* manager, set the value to zero.
*
* If the timeout operation is performed successfully, the method returns
* <i>true</i>; otherwise <i>false</i>. If a resource manager does not
* support explicitly setting the transaction timeout value, this method
* returns <i>false</i>.
*
* @param seconds The transaction timeout value in seconds.
*
* @return <i>true</i> if the transaction timeout value is set successfully;
* otherwise <i>false</i>.
*
* @exception XAException An error has occurred. Possible exception values
* are XAER_RMERR, XAER_RMFAIL, or XAER_INVAL.
*/
boolean setTransactionTimeout(int seconds) throws XAException;
/**
* Starts work on behalf of a transaction branch specified in
* <code>xid</code>.
*
* If TMJOIN is specified, the start applies to joining a transaction
* previously seen by the resource manager. If TMRESUME is specified,
* the start applies to resuming a suspended transaction specified in the
* parameter <code>xid</code>.
*
* If neither TMJOIN nor TMRESUME is specified and the transaction
* specified by <code>xid</code> has previously been seen by the resource
* manager, the resource manager throws the XAException exception with
* XAER_DUPID error code.
*
* @param xid A global transaction identifier to be associated
* with the resource.
*
* @param flags One of TMNOFLAGS, TMJOIN, or TMRESUME.
*
* @exception XAException An error has occurred. Possible exceptions
* are XA_RB*, XAER_RMERR, XAER_RMFAIL, XAER_DUPID, XAER_OUTSIDE,
* XAER_NOTA, XAER_INVAL, or XAER_PROTO.
*/
void start(Xid xid, int flags) throws XAException;
/**
* Ends a recovery scan.
*/
public final static int TMENDRSCAN = 0x00800000;
/**
* Disassociates the caller and marks the transaction branch
* rollback-only.
*/
public final static int TMFAIL = 0x20000000;
/**
* Caller is joining existing transaction branch.
*/
public final static int TMJOIN = 0x00200000;
/**
* Use TMNOFLAGS to indicate no flags value is selected.
*/
public final static int TMNOFLAGS = 0x00000000;
/**
* Caller is using one-phase optimization.
*/
public final static int TMONEPHASE = 0x40000000;
/**
* Caller is resuming association with a suspended
* transaction branch.
*/
public final static int TMRESUME = 0x08000000;
/**
* Starts a recovery scan.
*/
public final static int TMSTARTRSCAN = 0x01000000;
/**
* Disassociates caller from a transaction branch.
*/
public final static int TMSUCCESS = 0x04000000;
/**
* Caller is suspending (not ending) its association with
* a transaction branch.
*/
public final static int TMSUSPEND = 0x02000000;
/**
* The transaction branch has been read-only and has been committed.
*/
public final static int XA_RDONLY = 0x00000003;
/**
* The transaction work has been prepared normally.
*/
public final static int XA_OK = 0;
}

View file

@ -0,0 +1,72 @@
/*
* Copyright (c) 2000, 2002, 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 javax.transaction.xa;
/**
* The Xid interface is a Java mapping of the X/Open transaction identifier
* XID structure. This interface specifies three accessor methods to
* retrieve a global transaction format ID, global transaction ID,
* and branch qualifier. The Xid interface is used by the transaction
* manager and the resource managers. This interface is not visible to
* the application programs.
*
* @since 1.4
*/
public interface Xid {
/**
* Maximum number of bytes returned by {@link #getGlobalTransactionId }.
*/
final static int MAXGTRIDSIZE = 64;
/**
* Maximum number of bytes returned by {@link #getBranchQualifier }.
*/
final static int MAXBQUALSIZE = 64;
/**
* Obtain the format identifier part of the XID.
*
* @return Format identifier. O means the OSI CCR format.
*/
int getFormatId();
/**
* Obtain the global transaction identifier part of XID as an array
* of bytes.
*
* @return Global transaction identifier.
*/
byte[] getGlobalTransactionId();
/**
* Obtain the transaction branch identifier part of XID as an array
* of bytes.
*
* @return Global transaction identifier.
*/
byte[] getBranchQualifier();
}

View file

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<!--
Copyright (c) 2001, 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.
-->
</head>
<body bgcolor="white">
Provides the API that defines the contract between the transaction
manager and the resource manager, which allows the transaction
manager to enlist and delist resource objects (supplied by the
resource manager driver) in JTA transactions. The driver vendor
for a specific resource manager provides the implementation of
this API.
@since 1.4
</body>
</html>

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2014, 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.
*/
/**
* Defines the JDBC API.
*
* @uses java.sql.Driver
*
* @moduleGraph
* @since 9
*/
module java.sql {
requires transitive java.logging;
requires transitive java.xml;
exports java.sql;
exports javax.sql;
exports javax.transaction.xa;
uses java.sql.Driver;
}