Derby
  1. Derby
  2. DERBY-5239

Remove usages of DriverManager to obtain an Embedded Connection in Derby Server

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.6.1.0, 10.8.1.2
    • Fix Version/s: 10.8.2.2, 10.9.1.0
    • Component/s: Network Server
    • Labels:
      None
    • Urgency:
      Normal

      Description

      The Derby Network Server appears to look up the Derby Embedded Driver from the java.sql.DriverManager in a couple of places in order to get the connection to the actual database.

      This means the network server cannot operate in environments where for whatever reason it is not OK to access the embedded driver from the DriverManager. Just in general this behavior is unexpected as it should be possible to directly load the embedded driver.

      I've observed this issue in 10.6.1.0 and checked that the relevant usages are unchanged in trunk.

        Activity

        Hide
        Ed Costello added a comment -

        Attached is a patch replacing the two usages in Network Server with direct usage of the embedded driver.

        Show
        Ed Costello added a comment - Attached is a patch replacing the two usages in Network Server with direct usage of the embedded driver.
        Hide
        Kristian Waagan added a comment -

        Hi Ed,

        Thanks for the patch
        To allow the community to include your work in the code base, you have to grant a license to the ASF by ticking "Grant license to ASF for inclusion in ASF works (as per the Apache License §5)" on the upload page.
        For extra credit you could also generate the patch using "svn diff" from the root directory of the source code hierarchy.

        Show
        Kristian Waagan added a comment - Hi Ed, Thanks for the patch To allow the community to include your work in the code base, you have to grant a license to the ASF by ticking "Grant license to ASF for inclusion in ASF works (as per the Apache License §5)" on the upload page. For extra credit you could also generate the patch using "svn diff" from the root directory of the source code hierarchy.
        Hide
        Knut Anders Hatlen added a comment -

        Do you have an example where the current code causes problems? It might be helpful for the reviewers to understand what kind of problem the patch fixes.

        Show
        Knut Anders Hatlen added a comment - Do you have an example where the current code causes problems? It might be helpful for the reviewers to understand what kind of problem the patch fixes.
        Hide
        Knut Anders Hatlen added a comment -

        Ah, I see that my question has already been answered in a thread on derby-dev: http://mail-archives.apache.org/mod_mbox/db-derby-dev/201105.mbox/%3C1305683326.2425.34.camel@edwardc%3E

        Show
        Knut Anders Hatlen added a comment - Ah, I see that my question has already been answered in a thread on derby-dev: http://mail-archives.apache.org/mod_mbox/db-derby-dev/201105.mbox/%3C1305683326.2425.34.camel@edwardc%3E
        Hide
        Ed Costello added a comment -

        Apologies for not ticking the box, I'm too used to skimming the Jira Attach dialog.

        Attached is the same patch but generated from svn trunk svn-patch-Remove-Driver-Manager-Usage-from-Network-Server.patch Revision 1124404 & license box ticked.

        Show
        Ed Costello added a comment - Apologies for not ticking the box, I'm too used to skimming the Jira Attach dialog. Attached is the same patch but generated from svn trunk svn-patch-Remove-Driver-Manager-Usage-from-Network-Server.patch Revision 1124404 & license box ticked.
        Hide
        Dag H. Wanvik added a comment -

        The change looks ok to me. Can anybody see any issues with this change? I haven't really been much involved in this area...

        Show
        Dag H. Wanvik added a comment - The change looks ok to me. Can anybody see any issues with this change? I haven't really been much involved in this area...
        Hide
        Knut Anders Hatlen added a comment -

        The change looks fine to me too. The server code may now start using a different instance of the driver than the one found returned by DriverManager.getDriver(), but since all the methods of EmbeddedDriver end up calling static methods in AutoloadedDriver anyway, I don't think that it would cause any problems (like booting two engine instances in the same JVM).

        Show
        Knut Anders Hatlen added a comment - The change looks fine to me too. The server code may now start using a different instance of the driver than the one found returned by DriverManager.getDriver(), but since all the methods of EmbeddedDriver end up calling static methods in AutoloadedDriver anyway, I don't think that it would cause any problems (like booting two engine instances in the same JVM).
        Hide
        Ed Costello added a comment -

        As an aside, that exact scenario is happening in the environment that I've patched this for, embedded driver is being explicitly initialized by the OSGi Service managing drivers & a second instance is initialized by the Network Server using this patch. I've seen no ill affects from this though I haven't done more than trivial tests.

        Show
        Ed Costello added a comment - As an aside, that exact scenario is happening in the environment that I've patched this for, embedded driver is being explicitly initialized by the OSGi Service managing drivers & a second instance is initialized by the Network Server using this patch. I've seen no ill affects from this though I haven't done more than trivial tests.
        Hide
        Knut Anders Hatlen added a comment -

        All the regression tests ran cleanly with the patch.
        Committed revision 1126468.

        Thanks for fix, Ed!

        Show
        Knut Anders Hatlen added a comment - All the regression tests ran cleanly with the patch. Committed revision 1126468. Thanks for fix, Ed!
        Hide
        Knut Anders Hatlen added a comment -

        As a follow-up I've removed the (now unused) import statement that imports the DriverManager class in NetworkServerControlImpl. Committed revision 1136397.

        Show
        Knut Anders Hatlen added a comment - As a follow-up I've removed the (now unused) import statement that imports the DriverManager class in NetworkServerControlImpl. Committed revision 1136397.
        Hide
        Knut Anders Hatlen added a comment -

        Merged to 10.8. Committed revision 1138412.

        Show
        Knut Anders Hatlen added a comment - Merged to 10.8. Committed revision 1138412.
        Hide
        Knut Anders Hatlen added a comment -

        [bulk update] Close all resolved issues that haven't been updated for more than one year.

        Show
        Knut Anders Hatlen added a comment - [bulk update] Close all resolved issues that haven't been updated for more than one year.

          People

          • Assignee:
            Ed Costello
            Reporter:
            Ed Costello
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development