Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

JDBC Driver not fully compliant with JDBC specification (URL Parsing) #1170

Open
mmoss128 opened this issue May 27, 2022 · 0 comments
Open

Comments

@mmoss128
Copy link

What is the bug?
Current JDBC driver triggers a URL syntax exception for URI SyntaxException when parsing JDBC URL's which are not formatted for Open Distro for Elasticsearch. This means the driver can throw the exception any time a (valid) non-elasticsearch URL is processed. In the below example, an Oracle URL was provided on a system which had both Open Distro for Elasticsearch and Oracle JDBC drivers on the classpath. The Open Distro for Elasticsearch driver was loaded first and triggered the exception. Per JDBC Specification 4.3 (Section 9.2 Page 53), connection methods should return NULL when a URL does not match the driver specification.

Exception:
com.amazon.opendistroforelasticsearch.jdbc.config.ConnectionPropertyException: java.net.URISyntaxException: URL does not begin with the mandatory prefix jdbc:elasticsearch://.: jdbc:oracle://127.0.0.1:8080

JDBC Specification Excerpt:
When the DriverManager is trying to establish a connection, it calls that driver’s
connect method and passes the driver the URL. If the Driver implementation
understands the URL, it will return a Connection object or throw a SQLException
if a connection cannot be maded to the database. If the Driver implementation does
not understand the URL, it will return null

How can one reproduce the bug?
Steps to reproduce the behavior:
Note: Provided example are a manual way to reproduce as loading multiple drivers may not reproduce event.

Using a SQL Editor (Such as SQL Workbench) Create a new connection using the Open Distro for Elasticsearch driver, however provide a URL which is not in Open Distro for Elasticsearch Format.

Example:
image

SQL Server Driver Example:
image

What is the expected behavior?
Null should be returned by the driver when the connection URL does not match as described in JDBC Specification 4.3 (Section 9.2 Page 53)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant