pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
4+ messages / 2 participants
[nested] [flat]
* BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
@ 2011-03-31 13:09 Martin Handsteiner <martin.handsteiner@sibvisions.com>
0 siblings, 1 reply; 4+ messages in thread
From: Martin Handsteiner @ 2011-03-31 13:09 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged online:
Bug reference: 5961
Logged by: Martin Handsteiner
Email address: martin.handsteiner@sibvisions.com
PostgreSQL version: 9.0 Build 801
Operating system: All Operating Systems
Description: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
Details:
JDBC Driver acceptURL does not check 'jdbc:postgresql:'
We have to connect to several Databases on the server. Due to the wrong
implementation of acceptURL in the Postgres jdbc driver, connecting to any
other database is impossible.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
@ 2011-03-31 15:11 Kris Jurka <books@ejurka.com>
parent: Martin Handsteiner <martin.handsteiner@sibvisions.com>
0 siblings, 1 reply; 4+ messages in thread
From: Kris Jurka @ 2011-03-31 15:11 UTC (permalink / raw)
To: Martin Handsteiner <martin.handsteiner@sibvisions.com>; +Cc: pgsql-bugs
On Thu, 31 Mar 2011, Martin Handsteiner wrote:
>
> The following bug has been logged online:
>
> Bug reference: 5961
> PostgreSQL version: 9.0 Build 801
> Description: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
> Details:
>
> JDBC Driver acceptURL does not check 'jdbc:postgresql:'
I'm not sure what check you want it to make. It is a valid JDBC
connection string. Testing here shows that it falls back from a v3 to a
v2 protocol connection when a database name is not provided, but it does
still seem to work.
> We have to connect to several Databases on the server. Due to the wrong
> implementation of acceptURL in the Postgres jdbc driver, connecting to any
> other database is impossible.
>
I'm not sure what you mean. If you don't provide a database name, how do
you expect it to connect to different databases?
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
@ 2011-03-31 19:45 Kris Jurka <books@ejurka.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 4+ messages in thread
From: Kris Jurka @ 2011-03-31 19:45 UTC (permalink / raw)
To: DI Martin Handsteiner <martin.handsteiner@sibvisions.com>; +Cc: pgsql-bugs
On 3/31/2011 8:50 AM, DI Martin Handsteiner wrote:
>
> thank you very much for your fast response.
>
> The problem with the current implementation of acceptsURL in the the
> postgres driver is, that it also returns true if the connection url is like:
>
> jdbc:oraclethin:......
> jdbc:hsqldb:......
>
> That is the reason, why connections to other databases than postgres are not
> possible, if you use also a postgres driver.
I understand what your problem description is now, but I'm not seeing
that in a simple test case here. Can you provide the actual URLs that
make the attached code accept a non-postgresql URL?
Kris Jurka
Attachments:
Conn.java (text/x-java, 406B) download
import java.sql.Driver;
public class Conn {
public static void main(String args[]) throws Exception {
String urls[] = {
"jdbc:xx:postgresql",
"jdbc:xx:postgresql:xx",
"jdbc:xx:xx:postgresql",
"jdbc:hsqldb:.....",
"jdbc:oraclethin:..."
};
Driver driver = new org.postgresql.Driver();
for (String url : urls) {
System.out.println(url + " = " + driver.acceptsURL(url));
}
}
}
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
@ 2011-04-01 14:14 Kris Jurka <books@ejurka.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 4+ messages in thread
From: Kris Jurka @ 2011-04-01 14:14 UTC (permalink / raw)
To: DI Martin Handsteiner <martin.handsteiner@sibvisions.com>; +Cc: pgsql-bugs
On 4/1/2011 1:34 AM, DI Martin Handsteiner wrote:
>
> Here a working test case:
>
> Properties properties = new Properties();
> properties.setProperty("user", "sa");
> properties.setProperty("password", "");
> properties.put("shutdown", Boolean.TRUE);
>
> Connection hsqlConnection =
> DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/testdb",
> properties);
>
>
> The method acceptsUrl should not only check, if it finds some suitable
> properties,
> It should also check, if the url is ment for postgresql.
> In my opinion it should look like:
>
It turns out that DriverManager.getConnection does not call acceptsUrl
at all. It just tries to connect with each registered driver in turn.
Apparently acceptsUrl is only used for DriverManager.getDriver. So
changing acceptsUrl (which I maintain works just fine) won't help anything.
What's happening here is that the DriverManager tries to use the
postgresql Driver to establish a connection to the given URL, but it
ends up choking on the provided Properties before it can bail out
because it is not the correct URL. You should not use the Hashtable
inherited Properties.put method to insert non-string data into a
properties object because all keys and values should be Strings. If you
get rid of properties.put("shutdown", Boolean.TRUE), it works just fine.
Kris Jurka
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2011-04-01 14:14 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-03-31 13:09 BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:' Martin Handsteiner <martin.handsteiner@sibvisions.com>
2011-03-31 15:11 ` Kris Jurka <books@ejurka.com>
2011-03-31 19:45 ` Kris Jurka <books@ejurka.com>
2011-04-01 14:14 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox