Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8006505

Additional updates to support JSR 310 in JDBC

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b78

      Description

      For Types/JDBCType, we will:

      Add TIME_WITH_TIMEZONE
      Add TIMESTAMP_WITH_TIMEZONE

      We should be able to use DATE, TIME and TIMESTAMP with LocalDate, LocalTime, LocalDateTime

      Add the following methods to SQLInput & SQLOutput:


      SQLInput:


         /**
          * 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 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("readObject not implemented");
         }






      SQLOutput


       /**
        * 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 representing value to be sent to the database
        * @param targetSqlType the SQL type to convert the object to
        * @exception SQLException if a database access error occurs
        * @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("writeObject not implemented");
       }

        Attachments

          Activity

            People

            • Assignee:
              lancea Lance Andersen
              Reporter:
              lancea Lance Andersen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: