-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Hi,
I am having an issue with your library when I attempt to use it in conjunction with a Postgres data source.
The following very basic code:
final String url = DriverWrapper.POSTGIS_PROTOCOL + "//127.0.0.1:5432/postgres";
BaseDataSource ds = new PGSimpleDataSource();
ds.setUrl(url);
ds.setUser("postgres");
ds.setPassword("postgres");
Connection conn = ds.getConnection();
System.out.println(conn.toString());
Produces the error:
Exception in thread "main" java.lang.IllegalArgumentException: URL invalid jdbc:postgresql_postGIS://127.0.0.1:5443/postgres
at org.postgresql.ds.common.BaseDataSource.setUrl(BaseDataSource.java:1367)
at com.runwaysdk.Sandbox.main(Sandbox.java:76)
Due primarily to the fact that the Postgres BaseDataSource includes hardcoded assumptions that the jdbc protocol will always be 'postgresql'. See here and here.
Am I doing something wrong here? All of your test code appears to use the DriverManager.getConnection interface, which works because it bypasses that DataSource abstraction.
Additionally, I am unable to bypass your DriverWrapper, due to the fact that it is auto-loaded by the Java service loader paradigm. This causes issues because if I do not use the 'postgresql_postGIS' protocol, when DriverManager.getConnection is invoked via BaseDataSource.getConnection, the DriverWrapper throws a SQL exception Unknown protocol or subprotocol in url. This is already documented as an issue in ticket #113. As a result, I fear that my only path forward might be to repackage your jar without the META-INF service loader file, or to repackage the jar with a fix for #113 included.
Thanks