Details

    • Type: Sub-task Sub-task
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 10.0.2.1
    • Fix Version/s: None
    • Component/s: JDBC
    • Environment:
      Using DB2 universal driver with standalone derby server
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Deviation from standard, Embedded/Client difference

      Description

      ResultSetMetaData.isReadOnly() always returns true, even when writing to the table is possible.
      The JDBC 2.0 spec says: "ResultSetMetaData.isReadOnly() : Indicates whether the designated column is definitely not writable.", so the method should return false for a table.

      I will attach a testcase for this behaviour.

      1. TorqueTutorial.txt
        7 kB
        Jean T. Anderson
      2. DerbyTest142.java
        8 kB
      3. DerbyTest.java
        4 kB
        Thomas Fox

        Issue Links

          Activity

          Thomas Fox created issue -
          Thomas Fox made changes -
          Field Original Value New Value
          Attachment DerbyTest.java [ 18949 ]
          Anonymous made changes -
          Attachment DerbyTest142.java [ 12314771 ]
          Satheesh Bandaram made changes -
          Link This issue relates to DERBY-310 [ DERBY-310 ]
          Satheesh Bandaram made changes -
          Comment [ Here is more detailed test results on DB2. Ran this on 8.1.5, using IBM JCC driver bundled with that DB2 version. With DB2, it seems like FOR UPDATE/FOR READ ONLY clauses overwrite statement concurrancy.

          DerbyTest142 starting ...
          Default resultSetType and default concurrancy
                  Query: SELECT id, name FROM readonlytest
                          ID column isReadOnly = true
                          Name column isReadOnly = true
                  Query: SELECT id, name FROM readonlytest FOR UPDATE
                          ID column isReadOnly = false
                          Name column isReadOnly = false
                  Query: SELECT id, name FROM readonlytest FOR READ ONLY
                          ID column isReadOnly = true
                          Name column isReadOnly = true

          Forward-only resultSetType and CONCUR_UPDATABLE
                  Query: SELECT id, name FROM readonlytest
                          ID column isReadOnly = false
                          Name column isReadOnly = false
                  Query: SELECT id, name FROM readonlytest FOR UPDATE
                          ID column isReadOnly = false
                          Name column isReadOnly = false
                  Query: SELECT id, name FROM readonlytest FOR READ ONLY
                          ID column isReadOnly = true
                          Name column isReadOnly = true

          Forward-only resultSetType and CONCUR_READONLY
                  Query: SELECT id, name FROM readonlytest
                          ID column isReadOnly = true
                          Name column isReadOnly = true
                  Query: SELECT id, name FROM readonlytest FOR UPDATE
                          ID column isReadOnly = false
                          Name column isReadOnly = false
                  Query: SELECT id, name FROM readonlytest FOR READ ONLY
                          ID column isReadOnly = true
                          Name column isReadOnly = true

          Here is the program:

          public class DB2Test
          {
              public String protocol = "jdbc:db2://localhost:50000/";

              public static void main(String[] args) throws Exception
              {
                  System.out.println("DerbyTest142 starting ...");

                      Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
                      Connection conn = DriverManager.getConnection("jdbc:db2://localhost:50000/tdb",
                              "db2admin", "Pdb2adminW");

          System.out.println("Default resultSetType and default concurrancy");
                                    Statement s = conn.createStatement();
          printQueryInfo("SELECT id, name FROM readonlytest", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
          s.close();

          System.out.println("\nForward-only resultSetType and CONCUR_UPDATABLE");
                                    s = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
          printQueryInfo("SELECT id, name FROM readonlytest", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
                                   s.close();

          System.out.println("\nForward-only resultSetType and CONCUR_READONLY");
                                    s = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          printQueryInfo("SELECT id, name FROM readonlytest", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR UPDATE", s);
          printQueryInfo("SELECT id, name FROM readonlytest FOR READ ONLY", s);
                                   s.close();
                      conn.close();
              }

              public static void printQueryInfo(String query, Statement s) throws SQLException
              {
                  ResultSet rs = s.executeQuery(query);
                  ResultSetMetaData metaData = rs.getMetaData();
          System.out.println("\tQuery: "+query);
                  System.out.println("\t\tID column isReadOnly = " +metaData.isReadOnly(1));
                  System.out.println("\t\tName column isReadOnly = " +metaData.isReadOnly(2));
                  rs.close();
              }
          } ]
          Jean T. Anderson made changes -
          Attachment TorqueTutorial.txt [ 12314865 ]
          Knut Anders Hatlen made changes -
          Bug behavior facts [Deviation from standard, Embedded/Client difference]
          Urgency Normal
          Issue & fix info [Repro attached]
          Gavin made changes -
          Workflow jira [ 40091 ] Default workflow, editable Closed status [ 12801273 ]
          Mamta A. Satoor made changes -
          Labels derby_triage10_11

            People

            • Assignee:
              Unassigned
              Reporter:
              Thomas Fox
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development