vertx-sql-client icon indicating copy to clipboard operation
vertx-sql-client copied to clipboard

DB2ConnectionUriParser doesn't support standard DB2 URL character separators

Open blafond opened this issue 3 years ago • 0 comments

While trying to leverage the SqlConnectOptions.fromUri( URI uri) parsing feature in the SQL I ran into a problem with our DB2 url.

In Hibernate Reactive we're testing against DB2 via standard DB2 URL like:

  • jdbc:db2://localhost:52353/hreact:user=hreact;password=hreact;

This url is defined based on the IBM spec/doc and which uses a : colon as the separator between Database and parameter info and a ; semicolon between parameter key/value pairs.

However, the call to SqlConnectOptions.fromUri( URI uri) with this DB2 url will failed because vertx-db-client's parser doesn't recognize these separators. In stead it uses the same separators ( ? and & ) as it does with the other client parsers.

Was this intended? or is it a bug?

You can reproduce the error by adding these two tests (one succeeds, one fails) to: DB2ConnectionUriParserTest.java

  @Test
  public void testAlternateURL(){
    uri = "db2://localhost:4444/hreact?user=hreact&password=hreact";
    actualParsedResult = parse(uri);

    expectedParsedResult = new JsonObject()
      .put("user", "hreact")
      .put("password", "hreact")
      .put("host", "localhost")
      .put("port", 4444)
      .put("database", "hreact");

    assertEquals(expectedParsedResult, actualParsedResult);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testAlternateURLWithSemicolonFail(){
    uri = "db2://localhost:4444/hreact:user=hreact&password=hreact";
    actualParsedResult = parse(uri);
  }

blafond avatar Jan 13 '22 20:01 blafond