From: Kris Jurka <books@ejurka.com>
To: DI Martin Handsteiner <martin.handsteiner@sibvisions.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
Date: Fri, 01 Apr 2011 07:14:16 -0700
Message-ID: <4D95DDB8.2080809@ejurka.com> (raw)
In-Reply-To: <000001cbf047$b05e1090$111a31b0$@handsteiner@sibvisions.com>
References: <201103311309.p2VD9E8o097110@wwwmaster.postgresql.org>
<alpine.BSO.2.00.1103311056470.25650@leary.csoft.net>
<002d01cbefbb$4c6f8190$e54e84b0$@handsteiner@sibvisions.com>
<4D94D9E7.6080807@ejurka.com>
<000001cbf047$b05e1090$111a31b0$@handsteiner@sibvisions.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: books@ejurka.com, martin.handsteiner@sibvisions.com
Subject: Re: BUG #5961: JDBC Driver acceptURL does not check 'jdbc:postgresql:'
In-Reply-To: <4D95DDB8.2080809@ejurka.com>
References: <201103311309.p2VD9E8o097110@wwwmaster.postgresql.org> <alpine.BSO.2.00.1103311056470.25650@leary.csoft.net> <002d01cbefbb$4c6f8190$e54e84b0$@handsteiner@sibvisions.com> <4D94D9E7.6080807@ejurka.com> <000001cbf047$b05e1090$111a31b0$@handsteiner@sibvisions.com> <4D95DDB8.2080809@ejurka.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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