Description
software.amazon.dsql.jdbc.DSQLConnector.connect() currently throws SQLException for URLs that are not accepted by the Aurora DSQL JDBC connector.
Per the java.sql.Driver.connect contract, a driver should return null when it realizes it is the wrong driver for the URL, so DriverManager can try the next registered driver.
Version
Observed on latest JDBC tag: java/jdbc/v1.5.0.
Steps to reproduce
- Register/load the Aurora DSQL JDBC connector.
- Call:
Properties props = new Properties();
props.setProperty("user", "testuser");
Connection conn =
new DSQLConnector().connect("jdbc:postgresql://localhost:5432/postgres", props);
Actual behavior
connect() throws: SQLException: URL must be a valid Aurora DSQL URL
Expected behavior
connect() should return null because acceptsURL(...) returns false for that URL. This allows DriverManager to continue trying other registered JDBC drivers.
Reference
java.sql.Driver.connect specifies that a driver should return null when it is the wrong driver for the URL, and throw SQLException when it is the right driver but cannot connect. https://docs.oracle.com/cd/E13222_01/wls/docs/classdocs/java.sql.Driver.html
Proposed fix
At the start of DSQLConnector.connect():
if (url == null) {
throw new SQLException("URL is null");
}
if (!acceptsURL(url)) {
return null;
}
Description
software.amazon.dsql.jdbc.DSQLConnector.connect()currently throwsSQLExceptionfor URLs that are not accepted by the Aurora DSQL JDBC connector.Per the
java.sql.Driver.connectcontract, a driver should returnnullwhen it realizes it is the wrong driver for the URL, soDriverManagercan try the next registered driver.Version
Observed on latest JDBC tag:
java/jdbc/v1.5.0.Steps to reproduce
Actual behavior
connect() throws: SQLException: URL must be a valid Aurora DSQL URL
Expected behavior
connect() should return null because acceptsURL(...) returns false for that URL. This allows DriverManager to continue trying other registered JDBC drivers.
Reference
java.sql.Driver.connect specifies that a driver should return null when it is the wrong driver for the URL, and throw SQLException when it is the right driver but cannot connect. https://docs.oracle.com/cd/E13222_01/wls/docs/classdocs/java.sql.Driver.html
Proposed fix
At the start of DSQLConnector.connect():