Derby
  1. Derby
  2. DERBY-911

Connection.setReadOnly is a no-op in Network Client. It works fine with embedded client.

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 10.2.1.6
    • Fix Version/s: None
    • Component/s: Network Client
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Embedded/Client difference

      Description

      I have a simple test program which calls the Connection.setReadOnly(true) and then checks the readonly mode of that connection. In Network Server mode, the Connection.isReadOnly returns false even after Connection.setReadOnly(true). Same test program works fine when run in embedded mode, ie Connection.isReadOnly returns true after Connection.setReadOnly(true) is executed.

      Following is the test code snippet
      con = DriverManager.getConnection("jdbc:derby://localhost:1527/db7173;create=true", "APP", "APP");
      System.out.println("Check default connection.isReadOnly " + con.isReadOnly());
      con.setReadOnly(true);
      System.out.println("After connection.setReadOnly(true), what is isReadOnly " + con.isReadOnly());

      The output of this code in Network Server is as follows
      Check default connection.isReadOnly? false
      After connection.setReadOnly(true), what is isReadOnly? false

      I looked at the Network Client code and found the problem to be in the Network Client.
      org.apache.derby.client.am.Connection.setReadOnly method simply doesn't do anything with the supplied value, ie it doesn't pass any information to the Network Server for this call. In addition, it has following comment
      // This is a hint to the driver only, so this request is silently ignored.
      // PROTOCOL can only flow a set-read-only before the connection is established.

      In the same class, isReadOnly always returns false. This explains the current behavior of Network Server. But are we really limited by the DRDA protocol here as the comments in setReadOnly seem to imply?

      Anyone more familiar with DRDA specification and/or this code in Derby, can they share any information on DRDA spec and Derby behavior in this area?

        Issue Links

          Activity

          Gavin made changes -
          Workflow jira [ 12346540 ] Default workflow, editable Closed status [ 12796908 ]
          Kathey Marsden made changes -
          Labels derby_triage10_5_2 derby_triage10_9
          Kathey Marsden made changes -
          Labels derby_triage10_5_2
          Rick Hillegas made changes -
          Urgency Normal
          Issue & fix info [Repro attached]
          Kathey Marsden made changes -
          Derby Categories [Embedded/Client difference]
          Daniel John Debrunner made changes -
          Link This issue is related to DERBY-2738 [ DERBY-2738 ]
          Myrna van Lunteren made changes -
          Link This issue relates to DERBY-2492 [ DERBY-2492 ]
          Mamta A. Satoor made changes -
          Link This issue is part of DERBY-310 [ DERBY-310 ]
          Mamta A. Satoor made changes -
          Field Original Value New Value
          Summary Connection.setReadOnly is a no-op in Network Server. It works fine in embedded Derby. Connection.setReadOnly is a no-op in Network Client. It works fine with embedded client.
          Description I have a simple test program which calls the Connection.setReadOnly(true) and then checks the readonly mode of that connection. In Network Server, the Connection.isReadOnly returns false even after Connection.setReadOnly(true). Same test program works fine when run in embedded mode, ie Connection.isReadOnly returns true after Connection.setReadOnly(true) is executed.

          Following is the test code snippet
          con = DriverManager.getConnection("jdbc:derby://localhost:1527/db7173;create=true", "APP", "APP");
          System.out.println("Check default connection.isReadOnly " + con.isReadOnly());
          con.setReadOnly(true);
          System.out.println("After connection.setReadOnly(true), what is isReadOnly " + con.isReadOnly());

          The output of this code in Network Server is as follows
          Check default connection.isReadOnly? false
          After connection.setReadOnly(true), what is isReadOnly? false

          I looked at org.apache.derby.client.am.Connection.setReadOnly method and noticed that the method simply doesn't do anything with the supplied value. In addition, it has following comment
               // This is a hint to the driver only, so this request is silently ignored.
               // PROTOCOL can only flow a set-read-only before the connection is established.

          In the same class, isReadOnly always returns false. This explains the current behavior of Network Server. But are we really limited by the DRDA protocol here as the comments in setReadOnly seem to imply?

          Anyone more familiar with DRDA specification and/or this code in Derby, can they share any information on DRDA spec and Derby behavior in this area?
          I have a simple test program which calls the Connection.setReadOnly(true) and then checks the readonly mode of that connection. In Network Server mode, the Connection.isReadOnly returns false even after Connection.setReadOnly(true). Same test program works fine when run in embedded mode, ie Connection.isReadOnly returns true after Connection.setReadOnly(true) is executed.

          Following is the test code snippet
          con = DriverManager.getConnection("jdbc:derby://localhost:1527/db7173;create=true", "APP", "APP");
          System.out.println("Check default connection.isReadOnly " + con.isReadOnly());
          con.setReadOnly(true);
          System.out.println("After connection.setReadOnly(true), what is isReadOnly " + con.isReadOnly());

          The output of this code in Network Server is as follows
          Check default connection.isReadOnly? false
          After connection.setReadOnly(true), what is isReadOnly? false

          I looked at the Network Client code and found the problem to be in the Network Client.
          org.apache.derby.client.am.Connection.setReadOnly method simply doesn't do anything with the supplied value, ie it doesn't pass any information to the Network Server for this call. In addition, it has following comment
               // This is a hint to the driver only, so this request is silently ignored.
               // PROTOCOL can only flow a set-read-only before the connection is established.

          In the same class, isReadOnly always returns false. This explains the current behavior of Network Server. But are we really limited by the DRDA protocol here as the comments in setReadOnly seem to imply?

          Anyone more familiar with DRDA specification and/or this code in Derby, can they share any information on DRDA spec and Derby behavior in this area?
          Mamta A. Satoor created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Mamta A. Satoor
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Development