Derby
  1. Derby
  2. DERBY-944

Code ROWID methods for JDBC4 support

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.2.1.6
    • Component/s: JDBC
    • Labels:
      None

      Description

      As described in the JDBC4 spec sections 19 and 3.1.

      Derby does not support a stable ROWID datatype and we will not build this for release 10.2. The JDBC layer must report that Derby does not support this functionality. This involves stubbing out the RowId methods in DatabaseMetaData, ResultSet, PreparedStatement, and CallableStatement.

      1. DERBY-944-javadoc.diff
        2 kB
        Kristian Waagan
      2. DERBY-944-tests.diff
        21 kB
        Kristian Waagan
      3. DERBY-944.stat
        0.8 kB
        Kristian Waagan

        Activity

        Hide
        Rick Hillegas added a comment -

        Here is section 19 of the JDBC 4 spec:

        175
        This chapter describes the RowId data type that represents the SQL ROWID value in
        the Java programming language. A SQL ROWID is a built in type, as a value can be
        thought of as an address for a row in a SQL database table.
        19.1 Lifetime of RowId Validity
        The address may be logical or physical, however this is determined by the originating data
        source. A RowId object may be valid so long as the identified row is not deleted
        and the lifetime of the RowId is within the bounds of the lifetime specified by that
        RowId's data source.
        RowId object lifetime valdity may be determined by calling the
        DatabaseMetaData.getRowIdLifetime() method, which returns a value of the
        RowIdLifetime enumerated data-type.
        TABLE 19-1 Standard RowId life-time validities
        RowIdLifeTime Enumerated Datatype Specification
        ROWID_UNSUPPORTED Indicates that this data source does not support the
        ROWID type.
        ROWID_VALID_OTHER Indicates that the lifetime of a RowId from this data
        source is implentation dependant.
        176 JDBC 4.0 Specification ? October 2005
        19.2 Retrieving RowId Values
        A RowId may be retrieved using the getter methods defined in ResultSet and
        CallableStatement. The returned java.sql.RowId object that is returned is an
        immutable object that can be used for subsequent referrals as a unique identifier to a
        row.
        java.sql.RowId rowId_1 = rs.getRowId(1);
        CODE EXAMPLE 19-1 Retrieving a RowId for a ResultSet object, rs
        19.3 Using RowId Values
        A RowId value may be used in a parameterized PreparedStatement to set a
        parameter with a RowId object.
        Connection conn = ds.getConnection(user, passwd);
        PreparedStatement ps = conn.prepareStatement("INSERT INTO BOOKLIST" +
        "(ID, AUTHOR, TITLE, ISBN) VALUES (?, ?, ?,
        ?)");
        ps.setRowId(1, rowId_1);
        CODE EXAMPLE 19-2 Setting a PreparedStatement RowId parameter
        A RowId value may also be used in an updatable ResultSet to update a column with
        a specific RowId value.
        ROWID_VALID_TRANSACTION Indicates that the lifetime of a RowId from this data
        source is at least the containing transaction as long
        as the identified row is not deleted.
        ROWID_VALID_SESSION Indicates that the lifetime of a RowId from this data
        source is at least the containing session as long as
        the identified row is not deleted.
        ROWID_VALID_FOREVER Indicates that the lifetime of a RowId from this data
        source is, effectively, unlimited as long as the
        identified row is not deleted.
        TABLE 19-1 Standard RowId life-time validities
        RowIdLifeTime Enumerated Datatype Specification
        ResultSet rs = ...
        rs.next();
        rs.updateRowId(1, rowId_1);
        CODE EXAMPLE 19-3 Setting a RowId value in the current row of a ResultSet
        A RowId object value is typically not portable between data sources and should be
        considered as specific to the data source when using the set or update method in
        PreparedStatement and ResultSet objects respectively. It is therefore
        inadvisable to use a RowId retrieved from a ResultSet object with a connection
        'Foo' and then attempt to use the RowId in a unrelated ResultSet object with a
        connection 'Bar'.

        Show
        Rick Hillegas added a comment - Here is section 19 of the JDBC 4 spec: 175 This chapter describes the RowId data type that represents the SQL ROWID value in the Java programming language. A SQL ROWID is a built in type, as a value can be thought of as an address for a row in a SQL database table. 19.1 Lifetime of RowId Validity The address may be logical or physical, however this is determined by the originating data source. A RowId object may be valid so long as the identified row is not deleted and the lifetime of the RowId is within the bounds of the lifetime specified by that RowId's data source. RowId object lifetime valdity may be determined by calling the DatabaseMetaData.getRowIdLifetime() method, which returns a value of the RowIdLifetime enumerated data-type. TABLE 19-1 Standard RowId life-time validities RowIdLifeTime Enumerated Datatype Specification ROWID_UNSUPPORTED Indicates that this data source does not support the ROWID type. ROWID_VALID_OTHER Indicates that the lifetime of a RowId from this data source is implentation dependant. 176 JDBC 4.0 Specification ? October 2005 19.2 Retrieving RowId Values A RowId may be retrieved using the getter methods defined in ResultSet and CallableStatement. The returned java.sql.RowId object that is returned is an immutable object that can be used for subsequent referrals as a unique identifier to a row. java.sql.RowId rowId_1 = rs.getRowId(1); CODE EXAMPLE 19-1 Retrieving a RowId for a ResultSet object, rs 19.3 Using RowId Values A RowId value may be used in a parameterized PreparedStatement to set a parameter with a RowId object. Connection conn = ds.getConnection(user, passwd); PreparedStatement ps = conn.prepareStatement("INSERT INTO BOOKLIST" + "(ID, AUTHOR, TITLE, ISBN) VALUES (?, ?, ?, ?)"); ps.setRowId(1, rowId_1); CODE EXAMPLE 19-2 Setting a PreparedStatement RowId parameter A RowId value may also be used in an updatable ResultSet to update a column with a specific RowId value. ROWID_VALID_TRANSACTION Indicates that the lifetime of a RowId from this data source is at least the containing transaction as long as the identified row is not deleted. ROWID_VALID_SESSION Indicates that the lifetime of a RowId from this data source is at least the containing session as long as the identified row is not deleted. ROWID_VALID_FOREVER Indicates that the lifetime of a RowId from this data source is, effectively, unlimited as long as the identified row is not deleted. TABLE 19-1 Standard RowId life-time validities RowIdLifeTime Enumerated Datatype Specification ResultSet rs = ... rs.next(); rs.updateRowId(1, rowId_1); CODE EXAMPLE 19-3 Setting a RowId value in the current row of a ResultSet A RowId object value is typically not portable between data sources and should be considered as specific to the data source when using the set or update method in PreparedStatement and ResultSet objects respectively. It is therefore inadvisable to use a RowId retrieved from a ResultSet object with a connection 'Foo' and then attempt to use the RowId in a unrelated ResultSet object with a connection 'Bar'.
        Hide
        Kristian Waagan added a comment -

        Submitted tests for checking that methods related to RowId return the correct values or throw the correct exceptions.
        Converted some existing tests to Junit, and added "RowIdNotImplementedTest.junit" to the jdbc40 suite.

        The JavaDoc patch is for EmbedRowId. It is just a "shell", and I put it in a separate diff since I am not sure if we want to have it or not.

        Test runs under both embedded and DerbyNetClient without failures (JDK 1.6).

        Unless I have forgotten something, I do not plan to do more on this issue. Please review/commit patch.

        Show
        Kristian Waagan added a comment - Submitted tests for checking that methods related to RowId return the correct values or throw the correct exceptions. Converted some existing tests to Junit, and added "RowIdNotImplementedTest.junit" to the jdbc40 suite. The JavaDoc patch is for EmbedRowId. It is just a "shell", and I put it in a separate diff since I am not sure if we want to have it or not. Test runs under both embedded and DerbyNetClient without failures (JDK 1.6). Unless I have forgotten something, I do not plan to do more on this issue. Please review/commit patch.
        Hide
        Rick Hillegas added a comment -

        I applied DERBY-944-tests.diff. The jdbc4 tests run cleanly modulo the expected diff in StatementTest. I committed this patch at subversion revision 389571.

        Show
        Rick Hillegas added a comment - I applied DERBY-944 -tests.diff. The jdbc4 tests run cleanly modulo the expected diff in StatementTest. I committed this patch at subversion revision 389571.
        Hide
        Kristian Waagan added a comment -

        Closing issue.

        Show
        Kristian Waagan added a comment - Closing issue.

          People

          • Assignee:
            Kristian Waagan
            Reporter:
            Rick Hillegas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development