Derby
  1. Derby
  2. DERBY-618

Make the client driver connection URL work when spaces are in the URL.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.1.1.0
    • Fix Version/s: 10.1.3.1, 10.2.1.6
    • Component/s: Network Client
    • Labels:
      None

      Description

      At present, if I want to connect to a database on a Derby server which has a space in the path, there is no way to do it.

      This can be done with the embedded driver, and for consistency it would be good if it worked for the client driver in the same fashion.

      1. derby-618-10.1.diff
        9 kB
        Deepa Remesh
      2. derby-618-10.1.status
        0.5 kB
        Deepa Remesh
      3. derby-618-v2.diff
        9 kB
        Deepa Remesh
      4. derby-618-v2.status
        0.6 kB
        Deepa Remesh
      5. derby-618-script.sql
        0.2 kB
        Deepa Remesh
      6. derby-618.java
        6 kB
        Deepa Remesh
      7. derby-618-v1.diff
        0.9 kB
        Deepa Remesh
      8. derby-618-v1.status
        0.1 kB
        Deepa Remesh

        Activity

        Hide
        Trejkaz added a comment -

        I just tried doing this by modifying ClientDriver.java to remove the space separators from all StringTokenizer calls. If I do that, the connection works, but I get a new error a bit later on:

        Caused by: org.apache.derby.client.am.DisconnectException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location wh
        ere the error was detected: insufficient data. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS
        at org.apache.derby.client.net.NetAgent.throwCommunicationsFailure(NetAgent.java:362)
        at org.apache.derby.client.net.Reply.fill(Reply.java:193)
        at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Reply.java:212)
        at org.apache.derby.client.net.Reply.ensureBLayerDataInBuffer(Reply.java:225)
        at org.apache.derby.client.net.NetStatementReply.parsePKGNAMCSN(NetStatementReply.java:1478)
        at org.apache.derby.client.net.NetStatementReply.parsePKGSNLST(NetStatementReply.java:1721)
        at org.apache.derby.client.net.NetStatementReply.parseRSLSETRM(NetStatementReply.java:1080)
        at org.apache.derby.client.net.NetStatementReply.parseResultSetProcedure(NetStatementReply.java:343)
        at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(NetStatementReply.java:279)
        at org.apache.derby.client.net.NetStatementReply.readExecuteCall(NetStatementReply.java:97)
        at org.apache.derby.client.net.StatementReply.readExecuteCall(StatementReply.java:74)
        at org.apache.derby.client.net.NetStatement.readExecuteCall_(NetStatement.java:174)
        at org.apache.derby.client.am.Statement.readExecuteCall(Statement.java:1105)
        at org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:1426)
        at org.apache.derby.client.am.PreparedStatement.executeQueryX(PreparedStatement.java:299)
        at org.apache.derby.client.am.DatabaseMetaData.executeCatalogQuery(DatabaseMetaData.java:1767)
        at org.apache.derby.client.am.DatabaseMetaData.getTablesX(DatabaseMetaData.java:1148)
        at org.apache.derby.client.am.DatabaseMetaData.getTables(DatabaseMetaData.java:1101)
        at com.nuix.store.database.AbstractDatabase.tableExists(AbstractDatabase.java:189)
        ... 12 more

        Show
        Trejkaz added a comment - I just tried doing this by modifying ClientDriver.java to remove the space separators from all StringTokenizer calls. If I do that, the connection works, but I get a new error a bit later on: Caused by: org.apache.derby.client.am.DisconnectException: A communication error has been detected. Communication protocol being used: Reply.fill(). Communication API being used: InputStream.read(). Location wh ere the error was detected: insufficient data. Communication function detecting the error: *. Protocol specific error codes(s) TCP/IP SOCKETS at org.apache.derby.client.net.NetAgent.throwCommunicationsFailure(NetAgent.java:362) at org.apache.derby.client.net.Reply.fill(Reply.java:193) at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Reply.java:212) at org.apache.derby.client.net.Reply.ensureBLayerDataInBuffer(Reply.java:225) at org.apache.derby.client.net.NetStatementReply.parsePKGNAMCSN(NetStatementReply.java:1478) at org.apache.derby.client.net.NetStatementReply.parsePKGSNLST(NetStatementReply.java:1721) at org.apache.derby.client.net.NetStatementReply.parseRSLSETRM(NetStatementReply.java:1080) at org.apache.derby.client.net.NetStatementReply.parseResultSetProcedure(NetStatementReply.java:343) at org.apache.derby.client.net.NetStatementReply.parseEXCSQLSTTreply(NetStatementReply.java:279) at org.apache.derby.client.net.NetStatementReply.readExecuteCall(NetStatementReply.java:97) at org.apache.derby.client.net.StatementReply.readExecuteCall(StatementReply.java:74) at org.apache.derby.client.net.NetStatement.readExecuteCall_(NetStatement.java:174) at org.apache.derby.client.am.Statement.readExecuteCall(Statement.java:1105) at org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:1426) at org.apache.derby.client.am.PreparedStatement.executeQueryX(PreparedStatement.java:299) at org.apache.derby.client.am.DatabaseMetaData.executeCatalogQuery(DatabaseMetaData.java:1767) at org.apache.derby.client.am.DatabaseMetaData.getTablesX(DatabaseMetaData.java:1148) at org.apache.derby.client.am.DatabaseMetaData.getTables(DatabaseMetaData.java:1101) at com.nuix.store.database.AbstractDatabase.tableExists(AbstractDatabase.java:189) ... 12 more
        Hide
        Deepa Remesh added a comment -

        I tried this by removing the space separator in the call to nextToken method in tokenizeDatabase method in ClientDriver.java. With this change, I am able to create and connect to a database with spaces in its name. I tried few simple operations like creates, inserts and selects with the database.

        Trejkaz mentions a getting a disconnect exception when trying some operation with such a database. From the stack trace, it looks like Trejkaz was getting an exception in the call to DatabaseMetaData.getTables. I tried this in a small repro and did not get any exception with my patch. Anyone has any idea what exactly was being done to get the stack trace above ?

        Show
        Deepa Remesh added a comment - I tried this by removing the space separator in the call to nextToken method in tokenizeDatabase method in ClientDriver.java. With this change, I am able to create and connect to a database with spaces in its name. I tried few simple operations like creates, inserts and selects with the database. Trejkaz mentions a getting a disconnect exception when trying some operation with such a database. From the stack trace, it looks like Trejkaz was getting an exception in the call to DatabaseMetaData.getTables. I tried this in a small repro and did not get any exception with my patch. Anyone has any idea what exactly was being done to get the stack trace above ?
        Hide
        Deepa Remesh added a comment -

        Attaching a patch 'derby-618-v1.diff'. This is a one line change in ClientDriver.java. It removes the space separator in the call to nextToken method in tokenizeDatabase method. This allows use of database names with spaces.

        With this patch, I can create and connect to databases with spaces in the path or name. After connecting to such a database, I tried few simple operations. I did not get any exceptions. I think Trejkaz was getting an exception because previously network server also did not support database name with spaces. The problem at network server was resolved as part of DERBY-212/DERBY-814. Before this patch, parsePKGNAMCSN used to return a string with space separators (return rdbnam + " " + rdbcolid + " " + pkgid + " " + secnumber + " " + pkgcnstknStr. So, if the database name had spaces in it, it would'nt work when the pkgnamcsn string is parsed later. This has been already fixed in the trunk.

        I have not added any new regression test for this patch since we will be able to run the test only on Windows. I think test harness does not allow excluding tests based on an operating system. I have repros to test this and I'll upload them shortly.

        With the patch, I have run derbynetclientmats using Sun JDK 1.4.2 on Windows XP. No failures. I would appreciate if someone can take a look at this patch.

        Show
        Deepa Remesh added a comment - Attaching a patch 'derby-618-v1.diff'. This is a one line change in ClientDriver.java. It removes the space separator in the call to nextToken method in tokenizeDatabase method. This allows use of database names with spaces. With this patch, I can create and connect to databases with spaces in the path or name. After connecting to such a database, I tried few simple operations. I did not get any exceptions. I think Trejkaz was getting an exception because previously network server also did not support database name with spaces. The problem at network server was resolved as part of DERBY-212 / DERBY-814 . Before this patch, parsePKGNAMCSN used to return a string with space separators (return rdbnam + " " + rdbcolid + " " + pkgid + " " + secnumber + " " + pkgcnstknStr . So, if the database name had spaces in it, it would'nt work when the pkgnamcsn string is parsed later. This has been already fixed in the trunk. I have not added any new regression test for this patch since we will be able to run the test only on Windows. I think test harness does not allow excluding tests based on an operating system. I have repros to test this and I'll upload them shortly. With the patch, I have run derbynetclientmats using Sun JDK 1.4.2 on Windows XP. No failures. I would appreciate if someone can take a look at this patch.
        Hide
        Deepa Remesh added a comment -

        Ataching repros to test the patch:

        1. repro1: derby-618.java - This is a simple java program which creates and connects to a database with spaces in path. And then does some operations on the database.

        2. repro2: derby-618-script.sql - This is an ij script.

        To run the repros:
        1. Start network server on port 2222.
        2. For repro1, run the command 'java derby-618'.
        3. For repro 2, start ij and run the script 'derby-618-script.sql'.

        -----------------------------------
        Without the patch:
        -----------------------------------
        The repros will not give any exception when run without the patch. They will just create the wrong databases:

        • repro1 will create a database 'C:\directory'
        • repro2 will create a database 'test'

        -----------------------------------
        With the patch:
        -----------------------------------
        Repros should create the correct databases with spaces:

        • repro1 will create 'C:\directory with spaces\db name with spaces'
        • repro2 will create 'test db with spaces'
        Show
        Deepa Remesh added a comment - Ataching repros to test the patch: 1. repro1: derby-618.java - This is a simple java program which creates and connects to a database with spaces in path. And then does some operations on the database. 2. repro2: derby-618-script.sql - This is an ij script. To run the repros: 1. Start network server on port 2222. 2. For repro1, run the command 'java derby-618'. 3. For repro 2, start ij and run the script 'derby-618-script.sql'. ----------------------------------- Without the patch: ----------------------------------- The repros will not give any exception when run without the patch. They will just create the wrong databases: repro1 will create a database 'C:\directory' repro2 will create a database 'test' ----------------------------------- With the patch: ----------------------------------- Repros should create the correct databases with spaces: repro1 will create 'C:\directory with spaces\db name with spaces' repro2 will create 'test db with spaces'
        Hide
        Trejkaz added a comment -

        > I have not added any new regression test for this patch since we will be able to run the test only on Windows.

        Spaces exist on Linux as well, are you sure this issue only affected Windows?

        Show
        Trejkaz added a comment - > I have not added any new regression test for this patch since we will be able to run the test only on Windows. Spaces exist on Linux as well, are you sure this issue only affected Windows?
        Hide
        Deepa Remesh added a comment -

        Thanks for pointing this out. I think I can add a test to jdbcapi/checkDriver.java for an url with spaces in the database name. I had this wrong notion in my head that directory names with spaces apply only to Windows and hence not added a regression test. I see that other platforms allow creation of directory names with spaces, just that in some situations, it is recommended to avoid this. I will add this test and upload the new patch in a while.

        Show
        Deepa Remesh added a comment - Thanks for pointing this out. I think I can add a test to jdbcapi/checkDriver.java for an url with spaces in the database name. I had this wrong notion in my head that directory names with spaces apply only to Windows and hence not added a regression test. I see that other platforms allow creation of directory names with spaces, just that in some situations, it is recommended to avoid this. I will add this test and upload the new patch in a while.
        Hide
        Deepa Remesh added a comment -

        Attaching a patch 'derby-618-v2.diff' which includes code change and a test for this issue. Patch does the following:

        • Modifies ClientDriver.java - removes the space separator in the call to nextToken in tokenizeDatabase method. This allows use of URL containing database name with spaces.
        • Adds tests to jdbcapi/checkDriver.java for an url with spaces in database name. Since embedded and jcc driver work with spaces, I added this test for all three frameworks. Test verfies that the specified database gets created.
        • Modifies master files for the test

        Ran derbyall with Sun JDK 1.4.2 on Windows XP. I also ran jdbcapi/checkDriver.java with j9 vms. Please take a look at this patch. Thanks.

        Show
        Deepa Remesh added a comment - Attaching a patch 'derby-618-v2.diff' which includes code change and a test for this issue. Patch does the following: Modifies ClientDriver.java - removes the space separator in the call to nextToken in tokenizeDatabase method. This allows use of URL containing database name with spaces. Adds tests to jdbcapi/checkDriver.java for an url with spaces in database name. Since embedded and jcc driver work with spaces, I added this test for all three frameworks. Test verfies that the specified database gets created. Modifies master files for the test Ran derbyall with Sun JDK 1.4.2 on Windows XP. I also ran jdbcapi/checkDriver.java with j9 vms. Please take a look at this patch. Thanks.
        Hide
        Kathey Marsden added a comment -

        Checked this change into trunk but leaving opena and changing fixin to 10.1.2.3

        Date: Fri Mar 3 11:51:46 2006
        New Revision: 382917

        URL: http://svn.apache.org/viewcvs?rev=382917&view=rev

        Show
        Kathey Marsden added a comment - Checked this change into trunk but leaving opena and changing fixin to 10.1.2.3 Date: Fri Mar 3 11:51:46 2006 New Revision: 382917 URL: http://svn.apache.org/viewcvs?rev=382917&view=rev
        Hide
        Deepa Remesh added a comment -

        Attaching a patch 'derby-618-10.1.diff' for 10.1 branch. Submiiting a patch because revision #382917 could not be merged directly using svn merge command. This patch requires the changes in DERBY-814 to be applied to 10.1 branch first. This is uploaded as a separate patch at http://issues.apache.org/jira/browse/DERBY-814. Both these patches need to be committed together. I would appreciate if someone can look at these patches.

        Changes to resove the merge conflicts:

        • DERBY-618 - Manual merge was required for the test jdbcapi/checkDriver.java and masters since 10.1 branch tests hard-code localhost and do not have the test harness changes to get the host name.
        • DERBY-814 - Manual merge was required for DRDAConnThread.java (only conflict was in javadoc comments) and Database.java (had to change two methods to use the new class Pkgnamcsn)

        With both the patches applied, I ran the following tests:

        • derbyall with sane jars using Sun JDK 1.4.2. One failure in unit/T_Diagnosticable.unit. This test is failing with sane jars. It does not fail with sane classes. The test fails with sane jars even without the patches. The failure is same as what is reported in DERBY-496.
        • jdbcapi/checkDriver.java with j9 vms.

        NOTE: This patch has to be committed together with the 10.1 branch patch for DERBY-814 (derby-814-10.1.diff).

        Show
        Deepa Remesh added a comment - Attaching a patch 'derby-618-10.1.diff' for 10.1 branch. Submiiting a patch because revision #382917 could not be merged directly using svn merge command. This patch requires the changes in DERBY-814 to be applied to 10.1 branch first. This is uploaded as a separate patch at http://issues.apache.org/jira/browse/DERBY-814 . Both these patches need to be committed together. I would appreciate if someone can look at these patches. Changes to resove the merge conflicts: DERBY-618 - Manual merge was required for the test jdbcapi/checkDriver.java and masters since 10.1 branch tests hard-code localhost and do not have the test harness changes to get the host name. DERBY-814 - Manual merge was required for DRDAConnThread.java (only conflict was in javadoc comments) and Database.java (had to change two methods to use the new class Pkgnamcsn) With both the patches applied, I ran the following tests: derbyall with sane jars using Sun JDK 1.4.2. One failure in unit/T_Diagnosticable.unit. This test is failing with sane jars. It does not fail with sane classes. The test fails with sane jars even without the patches. The failure is same as what is reported in DERBY-496 . jdbcapi/checkDriver.java with j9 vms. NOTE: This patch has to be committed together with the 10.1 branch patch for DERBY-814 (derby-814-10.1.diff).
        Hide
        Kathey Marsden added a comment -

        Checked into 10.1.2.4

        'Date: Thu Mar 9 10:51:21 2006
        New Revision: 384581

        URL: http://svn.apache.org/viewcvs?rev=384581&view=rev

        Show
        Kathey Marsden added a comment - Checked into 10.1.2.4 'Date: Thu Mar 9 10:51:21 2006 New Revision: 384581 URL: http://svn.apache.org/viewcvs?rev=384581&view=rev
        Hide
        Myrna van Lunteren added a comment -

        Something had gone wrong in the update of the j9_13/checkDriver.out, username and password had gotten reversed. Updated master/canon with:
        http://svn.apache.org/viewvc?view=rev&revision=477004

        Show
        Myrna van Lunteren added a comment - Something had gone wrong in the update of the j9_13/checkDriver.out, username and password had gotten reversed. Updated master/canon with: http://svn.apache.org/viewvc?view=rev&revision=477004
        Hide
        Andrew McIntyre added a comment -

        This issue has been resolved for over a year with no further movement. Closing.

        Show
        Andrew McIntyre added a comment - This issue has been resolved for over a year with no further movement. Closing.

          People

          • Assignee:
            Deepa Remesh
            Reporter:
            Trejkaz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development