# HG changeset patch # User lancea # Date 1358610794 18000 # Node ID e081d3f73b752a1081a17a8c9ef8d0cf93027461 # Parent 245068ba31b3d879c6354dd21807f6bd389e3e57 8005080: JDBC 4.2 Core changes Reviewed-by: naoto diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/BatchUpdateException.java --- a/jdk/src/share/classes/java/sql/BatchUpdateException.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/BatchUpdateException.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,6 +25,10 @@ package java.sql; +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.util.Arrays; /** @@ -49,6 +53,15 @@ * commands, the array element for any command * that failed is Statement.EXECUTE_FAILED. *

+ * 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. + *

+ * 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 */ @@ -62,7 +75,11 @@ * initialized by a call to the * {@link Throwable#initCause(java.lang.Throwable)} method. *

- * + * Note: 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) }. + *

* @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 @@ -76,11 +93,14 @@ * 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); } /** @@ -92,7 +112,11 @@ * {@link Throwable#initCause(java.lang.Throwable)} method. The vendor code * is initialized to 0. *

- * + * Note: 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) }. + *

* @param reason a description of the exception * @param SQLState an XOPEN or SQL:2003 code identifying the exception * @param updateCounts an array of int, with each element @@ -104,6 +128,8 @@ * 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) { @@ -119,8 +145,11 @@ * SQLState is initialized to null * and the vender code is initialized to 0. *

- * - * + * Note: 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) }. + *

* @param reason a description of the exception * @param updateCounts an array of int, with each element * indicating the update count, Statement.SUCCESS_NO_INFO or @@ -131,6 +160,8 @@ * 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); @@ -144,7 +175,11 @@ * and SQLState are initialized to null and the vendor code * is initialized to 0. *

- * + * Note: 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) }. + *

* @param updateCounts an array of int, with each element * indicating the update count, Statement.SUCCESS_NO_INFO or * Statement.EXECUTE_FAILED for each SQL command in @@ -154,6 +189,8 @@ * 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); @@ -169,131 +206,167 @@ *

* * @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 BatchUpdateException object initialized with - * a given cause. - * The SQLState and updateCounts - * are initialized - * to null and the vendor code is initialized to 0. - * The reason is initialized to null if - * cause==null or to cause.toString() if - * cause!=null. - * @param cause the underlying reason for this SQLException - * (which is saved for later retrieval by the getCause() method); - * may be null indicating the cause is non-existent or unknown. - * @since 1.6 - */ - public BatchUpdateException(Throwable cause) { - this((cause == null ? null : cause.toString()), null, 0, null, cause); - } + /** + * Constructs a BatchUpdateException object initialized with + * a given cause. + * The SQLState and updateCounts + * are initialized + * to null and the vendor code is initialized to 0. + * The reason is initialized to null if + * cause==null or to cause.toString() if + * cause!=null. + * @param cause the underlying reason for this SQLException + * (which is saved for later retrieval by the getCause() 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 BatchUpdateException object initialized with a - * given cause and updateCounts. - * The SQLState is initialized - * to null and the vendor code is initialized to 0. - * The reason is initialized to null if - * cause==null or to cause.toString() if - * cause!=null. - * - * @param updateCounts an array of int, with each element - * indicating the update count, Statement.SUCCESS_NO_INFO or + /** + * Constructs a BatchUpdateException object initialized with a + * given cause and updateCounts. + * The SQLState is initialized + * to null and the vendor code is initialized to 0. + * The reason is initialized to null if + * cause==null or to cause.toString() if + * cause!=null. + *

+ * Note: 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) }. + *

+ * @param updateCounts an array of int, with each element + * indicating the update count, Statement.SUCCESS_NO_INFO or + * Statement.EXECUTE_FAILED for each SQL command in + * the batch for JDBC drivers that continue processing + * after a command failure; an update count or + * Statement.SUCCESS_NO_INFO 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 SQLException + * (which is saved for later retrieval by the getCause() 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 BatchUpdateException object initialized with + * a given reason, cause + * and updateCounts. The SQLState is initialized + * to null and the vendor code is initialized to 0. + *

+ * Note: 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) }. + *

+ * @param reason a description of the exception + * @param updateCounts an array of int, with each element + *indicating the update count, Statement.SUCCESS_NO_INFO or * Statement.EXECUTE_FAILED for each SQL command in * the batch for JDBC drivers that continue processing * after a command failure; an update count or * Statement.SUCCESS_NO_INFO 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 SQLException - * (which is saved for later retrieval by the getCause() method); may be null indicating - * the cause is non-existent or unknown. - * @since 1.6 - */ - public BatchUpdateException(int []updateCounts , Throwable cause) { - this((cause == null ? null : cause.toString()), null, 0, updateCounts, cause); - } + * @param cause the underlying reason for this SQLException (which is saved for later retrieval by the getCause() 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 BatchUpdateException object initialized with - * a given reason, cause - * and updateCounts. The SQLState is initialized - * to null and the vendor code is initialized to 0. - * - * @param reason a description of the exception - * @param updateCounts an array of int, with each element - *indicating the update count, Statement.SUCCESS_NO_INFO or + /** + * Constructs a BatchUpdateException object initialized with + * a given reason, SQLState,cause, and + * updateCounts. 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 int, with each element + * indicating the update count, Statement.SUCCESS_NO_INFO or * Statement.EXECUTE_FAILED for each SQL command in * the batch for JDBC drivers that continue processing * after a command failure; an update count or * Statement.SUCCESS_NO_INFO 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 SQLException (which is saved for later retrieval by the getCause() method); - * may be null indicating - * the cause is non-existent or unknown. - * @since 1.6 - */ - public BatchUpdateException(String reason, int []updateCounts, Throwable cause) { - this(reason, null, 0, updateCounts, cause); - } + *

+ * Note: 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) }. + *

+ * @param cause the underlying reason for this SQLException + * (which is saved for later retrieval by the getCause() 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 BatchUpdateException object initialized with - * a given reason, SQLState,cause, and - * updateCounts. 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 int, with each element - * indicating the update count, Statement.SUCCESS_NO_INFO or + /** + * Constructs a BatchUpdateException object initialized with + * a given reason, SQLState, vendorCode + * cause and updateCounts. + * + * @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 int, with each element + *indicating the update count, Statement.SUCCESS_NO_INFO or * Statement.EXECUTE_FAILED for each SQL command in * the batch for JDBC drivers that continue processing * after a command failure; an update count or * Statement.SUCCESS_NO_INFO 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 SQLException (which is saved for later retrieval by the getCause() method); - * may be null indicating - * the cause is non-existent or unknown. - * @since 1.6 - */ - public BatchUpdateException(String reason, String SQLState, - int []updateCounts, Throwable cause) { - this(reason, SQLState, 0, updateCounts, cause); - } - - /** - * Constructs a BatchUpdateException object initialized with - * a given reason, SQLState, vendorCode - * cause and updateCounts. - * - * @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 int, with each element - *indicating the update count, Statement.SUCCESS_NO_INFO or - * Statement.EXECUTE_FAILED for each SQL command in - * the batch for JDBC drivers that continue processing - * after a command failure; an update count or - * Statement.SUCCESS_NO_INFO 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 SQLException (which is saved for later retrieval by the getCause() method); - * may be null indicating - * the cause is non-existent or unknown. - * @since 1.6 - */ - public BatchUpdateException(String reason, String SQLState, int vendorCode, + *

+ * Note: 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) }. + *

+ * @param cause the underlying reason for this SQLException (which is saved for later retrieval by the getCause() 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 @@ -324,17 +397,168 @@ * failed to execute successfully * * @since 1.3 + * @see #getLargeUpdateCounts() */ public int[] getUpdateCounts() { return (updateCounts == null) ? null : Arrays.copyOf(updateCounts, updateCounts.length); } /** + * Constructs a BatchUpdateException object initialized with + * a given reason, SQLState, vendorCode + * cause and updateCounts. + *

+ * 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 long, with each element + *indicating the update count, Statement.SUCCESS_NO_INFO or + * Statement.EXECUTE_FAILED for each SQL command in + * the batch for JDBC drivers that continue processing + * after a command failure; an update count or + * Statement.SUCCESS_NO_INFO 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 SQLException + * (which is saved for later retrieval by the getCause() 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 BatchUpdateException was thrown. + *

+ * 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 long 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: + *

    + *
  1. an update count + *
  2. Statement.SUCCESS_NO_INFO to indicate that the command + * executed successfully but the number of rows affected is unknown + *
  3. Statement.EXECUTE_FAILED to indicate that the command + * failed to execute successfully + *
+ * @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 final int[] updateCounts; + 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: + * + * When any of the constructors are called, the int[] and long[] updateCount + * fields are populated by copying the one array to each other. + * + * As the JDBC driver passes in the updateCounts, there has always been the + * possiblity for overflow and BatchUpdateException does not need to account + * for that, it simply copies the arrays. + * + * JDBC drivers should always use the constructor that specifies long[] and + * JDBC application developers should call getLargeUpdateCounts. + */ + + /** + * The array that describes the outcome of a batch execution. + * @serial + * @since 1.8 + */ + private long[] longUpdateCounts; private static final long serialVersionUID = 5977529877145521757L; + + /* + * Utility method to copy int[] updateCount to long[] updateCount + */ + private static long[] copyUpdateCount(int[] uc) { + long[] copy = new long[uc.length]; + for(int i= 0; i< uc.length; i++) { + copy[i] = uc[i]; + } + return copy; + } + + /* + * Utility method to copy long[] updateCount to int[] updateCount. + * No checks for overflow will be done as it is expected a user will call + * getLargeUpdateCounts. + */ + private static int[] copyUpdateCount(long[] uc) { + int[] copy = new int[uc.length]; + for(int i= 0; i< uc.length; i++) { + copy[i] = (int) uc[i]; + } + return copy; + } + /** + * readObject is called to restore the state of the + * {@code BatchUpdateException} from a stream. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException { + + ObjectInputStream.GetField fields = s.readFields(); + int[] tmp = (int[])fields.get("updateCounts", null); + long[] tmp2 = (long[])fields.get("longUpdateCounts", null); + if(tmp != null && tmp2 != null && tmp.length != tmp2.length) + throw new InvalidObjectException("update counts are not the expected size"); + if (tmp != null) + updateCounts = tmp.clone(); + if (tmp2 != null) + longUpdateCounts = tmp2.clone(); + if(updateCounts == null && longUpdateCounts != null) + updateCounts = copyUpdateCount(longUpdateCounts); + if(longUpdateCounts == null && updateCounts != null) + longUpdateCounts = copyUpdateCount(updateCounts); + + } + + /** + * writeObject is called to save the state of the {@code BatchUpdateException} + * to a stream. + */ + private void writeObject(ObjectOutputStream s) + throws IOException, ClassNotFoundException { + + ObjectOutputStream.PutField fields = s.putFields(); + fields.put("updateCounts", updateCounts); + fields.put("longUpdateCounts", longUpdateCounts); + s.writeFields(); + } } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/CallableStatement.java --- a/jdk/src/share/classes/java/sql/CallableStatement.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/CallableStatement.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -1079,9 +1079,7 @@ int length) throws SQLException; /** - * Sets the value of the designated parameter with the given object. The second - * argument must be an object type; for integral values, the - * java.lang equivalent objects should be used. + * Sets the value of the designated parameter with the given object. * *

The given Java object will be converted to the given targetSqlType * before being sent to the database. @@ -1109,13 +1107,8 @@ * @exception SQLException if parameterName does not correspond to a named * parameter; if a database access error occurs or * this method is called on a closed CallableStatement - * @exception SQLFeatureNotSupportedException if targetSqlType is - * a ARRAY, BLOB, CLOB, - * DATALINK, JAVA_OBJECT, NCHAR, - * NCLOB, NVARCHAR, LONGNVARCHAR, - * REF, ROWID, SQLXML - * or STRUCT data type and the JDBC driver does not support - * this data type + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type * @see Types * @see #getObject * @since 1.4 @@ -1125,8 +1118,10 @@ /** * Sets the value of the designated parameter with the given object. - * This method is like the method setObject - * above, except that it assumes a scale of zero. + * + * This method is similar to {@link #setObject(String parameterName, + * Object x, int targetSqlType, int scaleOrLength)}, + * except that it assumes a scale of zero. * * @param parameterName the name of the parameter * @param x the object containing the input parameter value @@ -1135,13 +1130,8 @@ * @exception SQLException if parameterName does not correspond to a named * parameter; if a database access error occurs or * this method is called on a closed CallableStatement - * @exception SQLFeatureNotSupportedException if targetSqlType is - * a ARRAY, BLOB, CLOB, - * DATALINK, JAVA_OBJECT, NCHAR, - * NCLOB, NVARCHAR, LONGNVARCHAR, - * REF, ROWID, SQLXML - * or STRUCT data type and the JDBC driver does not support - * this data type + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type * @see #getObject * @since 1.4 */ @@ -1150,8 +1140,6 @@ /** * Sets the value of the designated parameter with the given object. - * The second parameter must be of type Object; therefore, the - * java.lang equivalent objects should be used for built-in types. * *

The JDBC specification specifies a standard mapping from * Java Object types to SQL types. The given argument @@ -2497,4 +2485,338 @@ */ public T getObject(String parameterName, Class type) throws SQLException; + //------------------------- JDBC 4.2 ----------------------------------- + + /** + *

Sets the value of the designated parameter with the given object. + * + * If the second argument is an {@code InputStream} then the stream + * must contain the number of bytes specified by scaleOrLength. + * If the second argument is a {@code Reader} then the reader must + * contain the number of characters specified + * by scaleOrLength. If these conditions are not true the driver + * will generate a + * {@code SQLException} when the prepared statement is executed. + * + *

The given Java object will be converted to the given targetSqlType + * before being sent to the database. + * + * 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. + * + *

Note that this method may be used to pass database-specific + * abstract data types. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterName the name of the parameter + * @param x the object containing the input parameter value + * @param targetSqlType the SQL type to be + * sent to the database. The scale argument may further qualify this type. + * @param scaleOrLength for {@code java.sql.JDBCType.DECIMAL} + * or {@code java.sql.JDBCType.NUMERIC types}, + * this is the number of digits after the decimal point. For + * Java Object types {@code InputStream} and {@code Reader}, + * this is the length + * of the data in the stream or reader. For all other types, + * this value will be ignored. + * @exception SQLException if parameterName does not correspond to a named + * parameter; if a database access error occurs + * or this method is called on a closed {@code CallableStatement} 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 setObject(String parameterName, Object x, SQLType targetSqlType, + int scaleOrLength) throws SQLException { + throw new SQLFeatureNotSupportedException("setObject not implemented"); + } + /** + * Sets the value of the designated parameter with the given object. + * + * This method is similar to {@link #setObject(String parameterName, + * Object x, SQLType targetSqlType, int scaleOrLength)}, + * except that it assumes a scale of zero. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterName the name of the parameter + * @param x the object containing the input parameter value + * @param targetSqlType the SQL type to be sent to the database + * @exception SQLException if parameterName does not correspond to a named + * parameter; if a database access error occurs + * or this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void setObject(String parameterName, Object x, SQLType targetSqlType) + throws SQLException { + throw new SQLFeatureNotSupportedException("setObject not implemented"); + } + + /** + * Registers the OUT parameter in ordinal position + * {@code parameterIndex} to the JDBC type + * {@code sqlType}. All OUT parameters must be registered + * before a stored procedure is executed. + *

+ * The JDBC type specified by {@code sqlType} for an OUT + * parameter determines the Java type that must be used + * in the {@code get} method to read the value of that parameter. + *

+ * If the JDBC type expected to be returned to this output parameter + * is specific to this particular database, {@code sqlType} + * may be {@code JDBCType.OTHER} or a {@code SQLType} that is supported by + * the JDBC driver. The method + * {@link #getObject} retrieves the value. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterIndex the first parameter is 1, the second is 2, + * and so on + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * If the parameter is of JDBC type {@code JDBCType.NUMERIC} + * or {@code JDBCType.DECIMAL}, the version of + * {@code registerOutParameter} that accepts a scale value + * should be used. + * + * @exception SQLException if the parameterIndex is not valid; + * if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void registerOutParameter(int parameterIndex, SQLType sqlType) + throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } + + /** + * Registers the parameter in ordinal position + * {@code parameterIndex} to be of JDBC type + * {@code sqlType}. All OUT parameters must be registered + * before a stored procedure is executed. + *

+ * The JDBC type specified by {@code sqlType} for an OUT + * parameter determines the Java type that must be used + * in the {@code get} method to read the value of that parameter. + *

+ * This version of {@code registrOutParameter} should be + * used when the parameter is of JDBC type {@code JDBCType.NUMERIC} + * or {@code JDBCType.DECIMAL}. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterIndex the first parameter is 1, the second is 2, + * and so on + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * @param scale the desired number of digits to the right of the + * decimal point. It must be greater than or equal to zero. + * @exception SQLException if the parameterIndex is not valid; + * if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void registerOutParameter(int parameterIndex, SQLType sqlType, + int scale) throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } + /** + * Registers the designated output parameter. + * This version of + * the method {@code registrOutParameter} + * should be used for a user-defined or {@code REF} output parameter. + * Examples + * of user-defined types include: {@code STRUCT}, {@code DISTINCT}, + * {@code JAVA_OBJECT}, and named array types. + *

+ * All OUT parameters must be registered + * before a stored procedure is executed. + *

For a user-defined parameter, the fully-qualified SQL + * type name of the parameter should also be given, while a {@code REF} + * parameter requires that the fully-qualified type name of the + * referenced type be given. A JDBC driver that does not need the + * type code and type name information may ignore it. To be portable, + * however, applications should always provide these values for + * user-defined and {@code REF} parameters. + * + * Although it is intended for user-defined and {@code REF} parameters, + * this method may be used to register a parameter of any JDBC type. + * If the parameter does not have a user-defined or {@code REF} type, the + * typeName parameter is ignored. + * + *

Note: When reading the value of an out parameter, you + * must use the getter method whose Java type corresponds to the + * parameter's registered SQL type. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterIndex the first parameter is 1, the second is 2,... + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * @param typeName the fully-qualified name of an SQL structured type + * @exception SQLException if the parameterIndex is not valid; + * if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void registerOutParameter (int parameterIndex, SQLType sqlType, + String typeName) throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } + + /** + * Registers the OUT parameter named + * parameterName to the JDBC type + * {@code sqlType}. All OUT parameters must be registered + * before a stored procedure is executed. + *

+ * The JDBC type specified by {@code sqlType} for an OUT + * parameter determines the Java type that must be used + * in the {@code get} method to read the value of that parameter. + *

+ * If the JDBC type expected to be returned to this output parameter + * is specific to this particular database, {@code sqlType} + * should be {@code JDBCType.OTHER} or a {@code SQLType} that is supported + * by the JDBC driver.. The method + * {@link #getObject} retrieves the value. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterName the name of the parameter + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * If the parameter is of JDBC type {@code JDBCType.NUMERIC} + * or {@code JDBCType.DECIMAL}, the version of + * {@code registrOutParameter} that accepts a scale value + * should be used. + * @exception SQLException if parameterName does not correspond to a named + * parameter; if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * or if the JDBC driver does not support + * this method + * @since 1.8 + * @see JDBCType + * @see SQLType + */ + default void registerOutParameter(String parameterName, SQLType sqlType) + throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } + + /** + * Registers the parameter named + * parameterName to be of JDBC type + * {@code sqlType}. All OUT parameters must be registered + * before a stored procedure is executed. + *

+ * The JDBC type specified by {@code sqlType} for an OUT + * parameter determines the Java type that must be used + * in the {@code get} method to read the value of that parameter. + *

+ * This version of {@code registrOutParameter} should be + * used when the parameter is of JDBC type {@code JDBCType.NUMERIC} + * or {@code JDBCType.DECIMAL}. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterName the name of the parameter + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * @param scale the desired number of digits to the right of the + * decimal point. It must be greater than or equal to zero. + * @exception SQLException if parameterName does not correspond to a named + * parameter; if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * or if the JDBC driver does not support + * this method + * @since 1.8 + * @see JDBCType + * @see SQLType + */ + default void registerOutParameter(String parameterName, SQLType sqlType, + int scale) throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } + + /** + * Registers the designated output parameter. This version of + * the method {@code registrOutParameter} + * should be used for a user-named or REF output parameter. Examples + * of user-named types include: STRUCT, DISTINCT, JAVA_OBJECT, and + * named array types. + *

+ * All OUT parameters must be registered + * before a stored procedure is executed. + *

+ * For a user-named parameter the fully-qualified SQL + * type name of the parameter should also be given, while a REF + * parameter requires that the fully-qualified type name of the + * referenced type be given. A JDBC driver that does not need the + * type code and type name information may ignore it. To be portable, + * however, applications should always provide these values for + * user-named and REF parameters. + * + * Although it is intended for user-named and REF parameters, + * this method may be used to register a parameter of any JDBC type. + * If the parameter does not have a user-named or REF type, the + * typeName parameter is ignored. + * + *

Note: When reading the value of an out parameter, you + * must use the {@code getXXX} method whose Java type XXX corresponds to the + * parameter's registered SQL type. + *

+ * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterName the name of the parameter + * @param sqlType the JDBC type code defined by {@code SQLType} to use to + * register the OUT Parameter. + * @param typeName the fully-qualified name of an SQL structured type + * @exception SQLException if parameterName does not correspond to a named + * parameter; if a database access error occurs or + * this method is called on a closed {@code CallableStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * or if the JDBC driver does not support this method + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void registerOutParameter (String parameterName, SQLType sqlType, + String typeName) throws SQLException { + throw new SQLFeatureNotSupportedException("registerOutParameter not implemented"); + } } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/DatabaseMetaData.java --- a/jdk/src/share/classes/java/sql/DatabaseMetaData.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/DatabaseMetaData.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -2522,10 +2522,10 @@ *

  • ASC_OR_DESC String => column sort sequence, "A" => ascending, * "D" => descending, may be null if sort sequence is not supported; * null when TYPE is tableIndexStatistic - *
  • CARDINALITY int => When TYPE is tableIndexStatistic, then + *
  • CARDINALITY long => When TYPE is tableIndexStatistic, then * this is the number of rows in the table; otherwise, it is the * number of unique values in the index. - *
  • PAGES int => When TYPE is tableIndexStatisic then + *
  • PAGES long => When TYPE is tableIndexStatisic then * this is the number of pages used for the table, otherwise it * is the number of pages used for the current index. *
  • FILTER_CONDITION String => Filter condition, if any. @@ -2759,7 +2759,7 @@ /** * Retrieves whether this database supports batch updates. * - * @return true if this database supports batch upcates; + * @return true if this database supports batch updates; * false otherwise * @exception SQLException if a database access error occurs * @since 1.2 @@ -3652,4 +3652,37 @@ * @since 1.7 */ boolean generatedKeyAlwaysReturned() throws SQLException; + + //--------------------------JDBC 4.2 ----------------------------- + + /** + * + * Retrieves the maximum number of bytes this database allows for + * the logical size for a {@code LOB}. + *

    + * The default implementation will return {@code 0} + * + * @return the maximum number of bytes allowed; a result of zero + * means that there is no limit or the limit is not known + * @exception SQLException if a database access error occurs + * @since 1.8 + */ + default long getMaxLogicalLobSize() throws SQLException { + return 0; + } + + /** + * Retrieves whether this database supports REF CURSOR. + *

    + * The default implementation will return {@code false} + * + * @return {@code true} if this database supports REF CURSOR; + * {@code false} otherwise + * @exception SQLException if a database access error occurs + * @since 1.8 + */ + default boolean supportsRefCursors() throws SQLException{ + return false; + } + } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/Driver.java --- a/jdk/src/share/classes/java/sql/Driver.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/Driver.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -65,10 +65,15 @@ * driver to connect to the given URL but has trouble connecting to * the database. * - *

    The java.util.Properties argument can be used to pass + *

    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 Properties object. + * included in the {@code Properties} object. + *

    + * Note: 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 @@ -76,7 +81,8 @@ * "password" property should be included. * @return a Connection object that represents a * connection to the URL - * @exception SQLException if a database access error occurs + * @exception SQLException if a database access error occurs or the url is + * {@code null} */ Connection connect(String url, java.util.Properties info) throws SQLException; @@ -84,13 +90,14 @@ /** * Retrieves whether the driver thinks that it can open a connection * to the given URL. Typically drivers will return true if they - * understand the subprotocol specified in the URL and false if + * understand the sub-protocol specified in the URL and false if * they do not. * * @param url the URL of the database * @return true if this driver understands the given URL; * false otherwise - * @exception SQLException if a database access error occurs + * @exception SQLException if a database access error occurs or the url is + * {@code null} */ boolean acceptsURL(String url) throws SQLException; diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/DriverManager.java --- a/jdk/src/share/classes/java/sql/DriverManager.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/DriverManager.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -172,6 +172,12 @@ * Attempts to establish a connection to the given database URL. * The DriverManager attempts to select an appropriate driver from * the set of registered JDBC drivers. + *

    + * Note: 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 * jdbc:subprotocol:subname @@ -179,7 +185,12 @@ * 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 + * @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 */ public static Connection getConnection(String url, java.util.Properties info) throws SQLException { @@ -195,6 +206,12 @@ * Attempts to establish a connection to the given database URL. * The DriverManager attempts to select an appropriate driver from * the set of registered JDBC drivers. + *

    + * Note: 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 * jdbc:subprotocol:subname @@ -202,7 +219,12 @@ * made * @param password the user's password * @return a connection to the URL - * @exception SQLException if a database access error occurs + * @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 */ public static Connection getConnection(String url, String user, String password) throws SQLException { @@ -230,7 +252,12 @@ * @param url a database url of the form * jdbc:subprotocol:subname * @return a connection to the URL - * @exception SQLException if a database access error occurs + * @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 */ public static Connection getConnection(String url) throws SQLException { @@ -380,7 +407,8 @@ /** * Sets the maximum time in seconds that a driver will wait - * while attempting to connect to a database. + * 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 diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/JDBCType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/sql/JDBCType.java Sat Jan 19 10:53:14 2013 -0500 @@ -0,0 +1,251 @@ +/* + * 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; + +/** + *

    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); + + /** + * 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; + } + + /** + * Returns the name of the data type. + * @return The name of the data type. + */ + 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."); + } +} diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/PreparedStatement.java --- a/jdk/src/share/classes/java/sql/PreparedStatement.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/PreparedStatement.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -388,23 +388,20 @@ /** * Sets the value of the designated parameter with the given object. - * This method is like the method setObject - * above, except that it assumes a scale of zero. + * + * This method is similar to {@link #setObject(int parameterIndex, + * Object x, int targetSqlType, int scaleOrLength)}, + * except that it assumes a scale of zero. * * @param parameterIndex the first parameter is 1, the second is 2, ... * @param x the object containing the input parameter value * @param targetSqlType the SQL type (as defined in java.sql.Types) to be * sent to the database * @exception SQLException if parameterIndex does not correspond to a parameter - * marker in the SQL statement; if a database access error occurs or - * this method is called on a closed PreparedStatement - * @exception SQLFeatureNotSupportedException if targetSqlType is - * a ARRAY, BLOB, CLOB, - * DATALINK, JAVA_OBJECT, NCHAR, - * NCLOB, NVARCHAR, LONGNVARCHAR, - * REF, ROWID, SQLXML - * or STRUCT data type and the JDBC driver does not support - * this data type + * marker in the SQL statement; if a database access error occurs or this + * method is called on a closed PreparedStatement + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type * @see Types */ void setObject(int parameterIndex, Object x, int targetSqlType) @@ -412,8 +409,6 @@ /** *

    Sets the value of the designated parameter using the given object. - * The second parameter must be of type Object; therefore, the - * java.lang equivalent objects should be used for built-in types. * *

    The JDBC specification specifies a standard mapping from * Java Object types to SQL types. The given argument @@ -914,9 +909,7 @@ void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException; /** - *

    Sets the value of the designated parameter with the given object. The second - * argument must be an object type; for integral values, the - * java.lang equivalent objects should be used. + *

    Sets the value of the designated parameter with the given object. * * If the second argument is an InputStream then the stream must contain * the number of bytes specified by scaleOrLength. If the second argument is a @@ -957,13 +950,8 @@ * 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 targetSqlType is - * a ARRAY, BLOB, CLOB, - * DATALINK, JAVA_OBJECT, NCHAR, - * NCLOB, NVARCHAR, LONGNVARCHAR, - * REF, ROWID, SQLXML - * or STRUCT data type and the JDBC driver does not support - * this data type + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type * @see Types * * @since 1.6 @@ -1220,5 +1208,114 @@ void setNClob(int parameterIndex, Reader reader) throws SQLException; + //------------------------- JDBC 4.2 ----------------------------------- + /** + *

    Sets the value of the designated parameter with the given object. + * + * If the second argument is an {@code InputStream} then the stream + * must contain the number of bytes specified by scaleOrLength. + * If the second argument is a {@code Reader} then the reader must + * contain the number of characters specified by scaleOrLength. If these + * conditions are not true the driver will generate a + * {@code SQLException} when the prepared statement is executed. + * + *

    The given Java object will be converted to the given targetSqlType + * before being sent to the database. + * + * 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. + * + *

    Note that this method may be used to pass database-specific + * abstract data types. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterIndex the first parameter is 1, the second is 2, ... + * @param x the object containing the input parameter value + * @param targetSqlType the SQL type to be sent to the database. The + * scale argument may further qualify this type. + * @param scaleOrLength for {@code java.sql.JDBCType.DECIMAL} + * or {@code java.sql.JDBCType.NUMERIC types}, + * this is the number of digits after the decimal point. For + * Java Object types {@code InputStream} and {@code Reader}, + * this is the length + * of the data in the stream or reader. For all other types, + * this value will be ignored. + * @exception SQLException if parameterIndex does not correspond to a + * parameter marker in the SQL statement; if a database access error occurs + * or this method is called on a closed {@code PreparedStatement} 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 setObject(int parameterIndex, Object x, SQLType targetSqlType, + int scaleOrLength) throws SQLException { + throw new SQLFeatureNotSupportedException("setObject not implemented"); + } + + /** + * Sets the value of the designated parameter with the given object. + * + * This method is similar to {@link #setObject(int parameterIndex, + * Object x, SQLType targetSqlType, int scaleOrLength)}, + * except that it assumes a scale of zero. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param parameterIndex the first parameter is 1, the second is 2, ... + * @param x the object containing the input parameter value + * @param targetSqlType the SQL type to be sent to the database + * @exception SQLException if parameterIndex does not correspond to a + * parameter marker in the SQL statement; if a database access error occurs + * or this method is called on a closed {@code PreparedStatement} + * @exception SQLFeatureNotSupportedException if + * the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void setObject(int parameterIndex, Object x, SQLType targetSqlType) + throws SQLException { + throw new SQLFeatureNotSupportedException("setObject not implemented"); + } + + /** + * Executes the SQL statement in this PreparedStatement object, + * which must be an SQL Data Manipulation Language (DML) statement, + * such as INSERT, UPDATE or + * DELETE; or an SQL statement that returns nothing, + * such as a DDL statement. + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * The default implementation will throw {@code UnsupportedOperationException} + * + * @return either (1) the row count for SQL Data Manipulation Language + * (DML) statements or (2) 0 for SQL statements that return nothing + * @exception SQLException if a database access error occurs; + * this method is called on a closed PreparedStatement + * or the SQL statement returns a ResultSet object + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * @since 1.8 + */ + default long executeLargeUpdate() throws SQLException { + throw new UnsupportedOperationException("executeLargeUpdate not implemented"); + } } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/ResultSet.java --- a/jdk/src/share/classes/java/sql/ResultSet.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/ResultSet.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -1834,6 +1834,7 @@ /** * Updates the designated column with an Object value. + * * The updater methods are used to update column values in the * current row or the insert row. The updater methods do not * update the underlying database; instead the updateRow or @@ -1866,6 +1867,7 @@ /** * Updates the designated column with an Object value. + * * The updater methods are used to update column values in the * current row or the insert row. The updater methods do not * update the underlying database; instead the updateRow or @@ -2224,6 +2226,7 @@ /** * Updates the designated column with an Object value. + * * The updater methods are used to update column values in the * current row or the insert row. The updater methods do not * update the underlying database; instead the updateRow or @@ -2256,6 +2259,7 @@ /** * Updates the designated column with an Object value. + * * The updater methods are used to update column values in the * current row or the insert row. The updater methods do not * update the underlying database; instead the updateRow or @@ -4142,4 +4146,145 @@ */ public T getObject(String columnLabel, Class type) throws SQLException; + //------------------------- JDBC 4.2 ----------------------------------- + + /** + * Updates the designated column with an {@code Object} value. + * + * The updater methods are used to update column values in the + * current row or the insert row. The updater methods do not + * update the underlying database; instead the {@code updateRow} or + * {@code insertRow} methods are called to update the database. + *

    + * If the second argument is an {@code InputStream} then the stream must contain + * the number of bytes specified by scaleOrLength. If the second argument is a + * {@code Reader} then the reader must contain the number of characters specified + * by scaleOrLength. If these conditions are not true the driver will generate a + * {@code SQLException} when the statement is executed. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param columnIndex the first column is 1, the second is 2, ... + * @param x the new column value + * @param targetSqlType the SQL type to be sent to the database + * @param scaleOrLength for an object of {@code java.math.BigDecimal} , + * this is the number of digits after the decimal point. For + * Java Object types {@code InputStream} and {@code Reader}, + * this is the length + * of the data in the stream or reader. For all other types, + * this value will be ignored. + * @exception SQLException if the columnIndex is not valid; + * if a database access error occurs; + * the result set concurrency is {@code CONCUR_READ_ONLY} + * or this method is called on a closed result set + * @exception SQLFeatureNotSupportedException if the JDBC driver does not + * support this method; if the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void updateObject(int columnIndex, Object x, + SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw new SQLFeatureNotSupportedException("updateObject not implemented"); + } + + /** + * Updates the designated column with an {@code Object} value. + * + * The updater methods are used to update column values in the + * current row or the insert row. The updater methods do not + * update the underlying database; instead the {@code updateRow} or + * {@code insertRow} methods are called to update the database. + *

    + * If the second argument is an {@code InputStream} then the stream must + * contain number of bytes specified by scaleOrLength. If the second + * argument is a {@code Reader} then the reader must contain the number + * of characters specified by scaleOrLength. If these conditions are not + * true the driver will generate a + * {@code SQLException} when the statement is executed. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param columnLabel the label for the column specified with the SQL AS + * clause. If the SQL AS clause was not specified, then the label is + * the name of the column + * @param targetSqlType the SQL type to be sent to the database + * @param scaleOrLength for an object of {@code java.math.BigDecimal} , + * this is the number of digits after the decimal point. For + * Java Object types {@code InputStream} and {@code Reader}, + * this is the length + * of the data in the stream or reader. For all other types, + * this value will be ignored. + * @exception SQLException if the columnLabel is not valid; + * if a database access error occurs; + * the result set concurrency is {@code CONCUR_READ_ONLY} + * or this method is called on a closed result set + * @exception SQLFeatureNotSupportedException if the JDBC driver does not + * support this method; if the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void updateObject(String columnLabel, Object x, + SQLType targetSqlType, int scaleOrLength) throws SQLException { + throw new SQLFeatureNotSupportedException("updateObject not implemented"); + } + + /** + * Updates the designated column with an {@code Object} value. + * + * The updater methods are used to update column values in the + * current row or the insert row. The updater methods do not + * update the underlying database; instead the {@code updateRow} or + * {@code insertRow} methods are called to update the database. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param columnIndex the first column is 1, the second is 2, ... + * @param x the new column value + * @param targetSqlType the SQL type to be sent to the database + * @exception SQLException if the columnIndex is not valid; + * if a database access error occurs; + * the result set concurrency is {@code CONCUR_READ_ONLY} + * or this method is called on a closed result set + * @exception SQLFeatureNotSupportedException if the JDBC driver does not + * support this method; if the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void updateObject(int columnIndex, Object x, SQLType targetSqlType) + throws SQLException { + throw new SQLFeatureNotSupportedException("updateObject not implemented"); + } + + /** + * Updates the designated column with an {@code Object} value. + * + * The updater methods are used to update column values in the + * current row or the insert row. The updater methods do not + * update the underlying database; instead the {@code updateRow} or + * {@code insertRow} methods are called to update the database. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param columnLabel the label for the column specified with the SQL AS + * clause. If the SQL AS clause was not specified, then the label is + * the name of the column + * @param x the new column value + * @param targetSqlType the SQL type to be sent to the database + * @exception SQLException if the columnLabel is not valid; + * if a database access error occurs; + * the result set concurrency is {@code CONCUR_READ_ONLY} + * or this method is called on a closed result set + * @exception SQLFeatureNotSupportedException if the JDBC driver does not + * support this method; if the JDBC driver does not support this data type + * @see JDBCType + * @see SQLType + * @since 1.8 + */ + default void updateObject(String columnLabel, Object x, + SQLType targetSqlType) throws SQLException { + throw new SQLFeatureNotSupportedException("updateObject not implemented"); + } } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/SQLTimeoutException.java --- a/jdk/src/share/classes/java/sql/SQLTimeoutException.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/SQLTimeoutException.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,8 +26,10 @@ package java.sql; /** - *

    The subclass of {@link SQLException} thrown when the timeout specified by Statement - * has expired. + *

    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. *

    This exception does not correspond to a standard SQLState. * * @since 1.6 diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/SQLType.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/java/sql/SQLType.java Sat Jan 19 10:53:14 2013 -0500 @@ -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(); +} diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/Statement.java --- a/jdk/src/share/classes/java/sql/Statement.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/Statement.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -183,7 +183,15 @@ * Sets escape processing on or off. * If escape scanning is on (the default), the driver will do * escape substitution before sending the SQL statement to the database. - * + *

    + * The {@code Connection} and {@code DataSource} property + * {@code escapeProcessing} may be used to change the default escape processing + * behavior. A value of true (the default) enables escape Processing for + * all {@code Statement} objects. A value of false disables escape processing + * for all {@code Statement} objects. The {@code setEscapeProcessing} + * method may be used to specify the escape processing behavior for an + * individual {@code Statement} object. + *

    * Note: Since prepared statements have usually been parsed prior * to making this call, disabling escape processing for * PreparedStatements objects will have no effect. @@ -1060,4 +1068,304 @@ */ public boolean isCloseOnCompletion() throws SQLException; + + //--------------------------JDBC 4.2 ----------------------------- + + /** + * Retrieves the current result as an update count; if the result + * is a ResultSet object or there are no more results, -1 + * is returned. This method should be called only once per result. + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * The default implementation will throw {@code UnsupportedOperationException} + * + * @return the current result as an update count; -1 if the current result + * is a ResultSet object or there are no more results + * @exception SQLException if a database access error occurs or + * this method is called on a closed Statement + * @see #execute + * @since 1.8 + */ + default long getLargeUpdateCount() throws SQLException { + throw new UnsupportedOperationException("getLargeUpdateCount not implemented"); + } + + /** + * Sets the limit for the maximum number of rows that any + * ResultSet object generated by this Statement + * object can contain to the given number. + * If the limit is exceeded, the excess + * rows are silently dropped. + *

    + * This method should be used when the row limit may exceed + * {@link Integer.MAX_VALUE}. + *

    + * The default implementation will throw {@code UnsupportedOperationException} + * + * @param max the new max rows limit; zero means there is no limit + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement + * or the condition max >= 0 is not satisfied + * @see #getMaxRows + * @since 1.8 + */ + default void setLargeMaxRows(long max) throws SQLException { + throw new UnsupportedOperationException("setLargeMaxRows not implemented"); + } + + /** + * Retrieves the maximum number of rows that a + * ResultSet object produced by this + * Statement object can contain. If this limit is exceeded, + * the excess rows are silently dropped. + *

    + * This method should be used when the returned row limit may exceed + * {@link Integer.MAX_VALUE}. + *

    + * The default implementation will return {@code 0} + * + * @return the current maximum number of rows for a ResultSet + * object produced by this Statement object; + * zero means there is no limit + * @exception SQLException if a database access error occurs or + * this method is called on a closed Statement + * @see #setMaxRows + * @since 1.8 + */ + default long getLargeMaxRows() throws SQLException { + return 0; + } + + /** + * Submits a batch of commands to the database for execution and + * if all commands execute successfully, returns an array of update counts. + * The long elements of the array that is returned are ordered + * to correspond to the commands in the batch, which are ordered + * according to the order in which they were added to the batch. + * The elements in the array returned by the method {@code executeLargeBatch} + * may be one of the following: + *

      + *
    1. A number greater than or equal to zero -- indicates that the + * command was processed successfully and is an update count giving the + * number of rows in the database that were affected by the command's + * execution + *
    2. A value of SUCCESS_NO_INFO -- indicates that the command was + * processed successfully but that the number of rows affected is + * unknown + *

      + * If one of the commands in a batch update fails to execute properly, + * this method throws a BatchUpdateException, and a JDBC + * driver may or may not continue to process the remaining commands in + * the batch. However, the driver's behavior must be consistent with a + * particular DBMS, either always continuing to process commands or never + * continuing to process commands. If the driver continues processing + * after a failure, the array returned by the method + * BatchUpdateException.getLargeUpdateCounts + * will contain as many elements as there are commands in the batch, and + * at least one of the elements will be the following: + *

      + *

    3. A value of EXECUTE_FAILED -- indicates that the command failed + * to execute successfully and occurs only if a driver continues to + * process commands after a command fails + *
    + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * The default implementation will throw {@code UnsupportedOperationException} + * + * @return an array of update counts containing one element for each + * command in the batch. The elements of the array are ordered according + * to the order in which commands were added to the batch. + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement or the + * driver does not support batch statements. Throws {@link BatchUpdateException} + * (a subclass of SQLException) if one of the commands sent to the + * database fails to execute properly or attempts to return a result set. + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * + * @see #addBatch + * @see DatabaseMetaData#supportsBatchUpdates + * @since 1.8 + */ + default long[] executeLargeBatch() throws SQLException { + throw new UnsupportedOperationException("executeLargeBatch not implemented"); + } + + /** + * Executes the given SQL statement, which may be an INSERT, + * UPDATE, or DELETE statement or an + * SQL statement that returns nothing, such as an SQL DDL statement. + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * Note:This method cannot be called on a + * PreparedStatement or CallableStatement. + *

    + * The default implementation will throw {@code UnsupportedOperationException} + * + * @param sql an SQL Data Manipulation Language (DML) statement, + * such as INSERT, UPDATE or + * DELETE; or an SQL statement that returns nothing, + * such as a DDL statement. + * + * @return either (1) the row count for SQL Data Manipulation Language + * (DML) statements or (2) 0 for SQL statements that return nothing + * + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement, the given + * SQL statement produces a ResultSet object, the method is called on a + * PreparedStatement or CallableStatement + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * @since 1.8 + */ + default long executeLargeUpdate(String sql) throws SQLException { + throw new UnsupportedOperationException("executeLargeUpdate not implemented"); + } + + /** + * Executes the given SQL statement and signals the driver with the + * given flag about whether the + * auto-generated keys produced by this Statement object + * should be made available for retrieval. The driver will ignore the + * flag if the SQL statement + * is not an INSERT statement, or an SQL statement able to return + * auto-generated keys (the list of such statements is vendor-specific). + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * Note:This method cannot be called on a + * PreparedStatement or CallableStatement. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param sql an SQL Data Manipulation Language (DML) statement, + * such as INSERT, UPDATE or + * DELETE; or an SQL statement that returns nothing, + * such as a DDL statement. + * + * @param autoGeneratedKeys a flag indicating whether auto-generated keys + * should be made available for retrieval; + * one of the following constants: + * Statement.RETURN_GENERATED_KEYS + * Statement.NO_GENERATED_KEYS + * @return either (1) the row count for SQL Data Manipulation Language (DML) statements + * or (2) 0 for SQL statements that return nothing + * + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement, the given + * SQL statement returns a ResultSet object, + * the given constant is not one of those allowed, the method is called on a + * PreparedStatement or CallableStatement + * @exception SQLFeatureNotSupportedException if the JDBC driver does not support + * this method with a constant of Statement.RETURN_GENERATED_KEYS + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * @since 1.8 + */ + default long executeLargeUpdate(String sql, int autoGeneratedKeys) + throws SQLException { + throw new SQLFeatureNotSupportedException("executeLargeUpdate not implemented"); + } + + /** + * Executes the given SQL statement and signals the driver that the + * auto-generated keys indicated in the given array should be made available + * for retrieval. This array contains the indexes of the columns in the + * target table that contain the auto-generated keys that should be made + * available. The driver will ignore the array if the SQL statement + * is not an INSERT statement, or an SQL statement able to return + * auto-generated keys (the list of such statements is vendor-specific). + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * Note:This method cannot be called on a + * PreparedStatement or CallableStatement. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param sql an SQL Data Manipulation Language (DML) statement, + * such as INSERT, UPDATE or + * DELETE; or an SQL statement that returns nothing, + * such as a DDL statement. + * + * @param columnIndexes an array of column indexes indicating the columns + * that should be returned from the inserted row + * @return either (1) the row count for SQL Data Manipulation Language (DML) statements + * or (2) 0 for SQL statements that return nothing + * + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement, the SQL + * statement returns a ResultSet object,the second argument + * supplied to this method is not an + * int array whose elements are valid column indexes, the method is called on a + * PreparedStatement or CallableStatement + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * @since 1.8 + */ + default long executeLargeUpdate(String sql, int columnIndexes[]) throws SQLException { + throw new SQLFeatureNotSupportedException("executeLargeUpdate not implemented"); + } + + /** + * Executes the given SQL statement and signals the driver that the + * auto-generated keys indicated in the given array should be made available + * for retrieval. This array contains the names of the columns in the + * target table that contain the auto-generated keys that should be made + * available. The driver will ignore the array if the SQL statement + * is not an INSERT statement, or an SQL statement able to return + * auto-generated keys (the list of such statements is vendor-specific). + *

    + * This method should be used when the returned row count may exceed + * {@link Integer.MAX_VALUE}. + *

    + * Note:This method cannot be called on a + * PreparedStatement or CallableStatement. + *

    + * The default implementation will throw {@code SQLFeatureNotSupportedException} + * + * @param sql an SQL Data Manipulation Language (DML) statement, + * such as INSERT, UPDATE or + * DELETE; or an SQL statement that returns nothing, + * such as a DDL statement. + * @param columnNames an array of the names of the columns that should be + * returned from the inserted row + * @return either the row count for INSERT, UPDATE, + * or DELETE statements, or 0 for SQL statements + * that return nothing + * @exception SQLException if a database access error occurs, + * this method is called on a closed Statement, the SQL + * statement returns a ResultSet object, the + * second argument supplied to this method is not a String array + * whose elements are valid column names, the method is called on a + * PreparedStatement or CallableStatement + * @throws SQLFeatureNotSupportedException if the JDBC driver does not support this method + * @throws SQLTimeoutException when the driver has determined that the + * timeout value that was specified by the {@code setQueryTimeout} + * method has been exceeded and has at least attempted to cancel + * the currently running {@code Statement} + * @since 1.8 + */ + default long executeLargeUpdate(String sql, String columnNames[]) + throws SQLException { + throw new SQLFeatureNotSupportedException("executeLargeUpdate not implemented"); + } } + diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/Types.java --- a/jdk/src/share/classes/java/sql/Types.java Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/Types.java Sat Jan 19 10:53:14 2013 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -309,6 +309,16 @@ */ 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; + // Prevent instantiation private Types() {} } diff -r 245068ba31b3 -r e081d3f73b75 jdk/src/share/classes/java/sql/package.html --- a/jdk/src/share/classes/java/sql/package.html Sat Jan 19 10:11:19 2013 -0500 +++ b/jdk/src/share/classes/java/sql/package.html Sat Jan 19 10:53:14 2013 -0500 @@ -2,7 +2,7 @@