Re: Avoiding explicit addDataType calls for PostGIS

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Markus Schaber <schabios(at)logi-track(dot)com>
Cc: PostGreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Avoiding explicit addDataType calls for PostGIS
Date: 2004-10-12 04:55:27
Message-ID: 416B63BF.4090304@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Markus Schaber wrote:
> Hi, Oliver,
>
> On Thu, 07 Oct 2004 10:11:22 +1300
> Oliver Jowett <oliver(at)opencloud(dot)com> wrote:
>
>>If your objective is to produce a driver that automatically supports
>>the extra datatypes, how about a provider-properties-file approach?
>
> That is a nice idea that allows to control default configuration without
> recompiling, and without explicit code in the app.

Here is a first cut at implementing this.

The driver looks for resources named "postgresql.properties" in its
classloader, loads them as property files in the order the classloader
returns them, and uses the result as default properties. These defaults
are overridden in turn by user-provided properties and properties
extracted from the connection URL.

Properties of the form datatype.<typename>=<classname> cause the given
class to be loaded and registered via addDataType. The default set of
datatypes (interval, money, line, etc) are registered in this way by a
default postgresql.properties included in the driver jar.

I haven't looked at preventing user properties from causing classloading
yet.. don't know if it is worth it.

Also I have not investigated the exact order of resources that
ClassLoader.getResources() returns; it might need some tuning.

-O

Attachment Content-Type Size
pgjdbc-properties-from-classpath.txt text/plain 7.4 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stuart Bishop 2004-10-12 05:04:20 'NOW' in UTC with no timezone
Previous Message Michael Fuhr 2004-10-12 04:51:15 Re: Reiniciar secuencias

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ulrich Meis 2004-10-12 05:17:13 Re: A solution to the SSL customizing problem
Previous Message Oliver Jowett 2004-10-12 04:34:04 Re: A solution to the SSL customizing problem