X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B471E32A13E for ; Thu, 7 Oct 2004 09:53:05 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93727-10 for ; Thu, 7 Oct 2004 08:52:33 +0000 (GMT) Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) by svr1.postgresql.org (Postfix) with ESMTP id 46F0932A399 for ; Thu, 7 Oct 2004 09:51:08 +0100 (BST) Received: from kingfisher.intern.logi-track.com (G7ed7.g.pppool.de [80.185.126.215]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logi-track.com (Postfix) with ESMTP id 570763016F; Thu, 7 Oct 2004 10:46:12 +0200 (CEST) Received: from kingfisher.intern.logi-track.com (localhost [127.0.0.1]) by kingfisher.intern.logi-track.com (Postfix) with SMTP id D72DFAB2E1; Thu, 7 Oct 2004 10:46:05 +0200 (CEST) Date: Thu, 7 Oct 2004 10:46:03 +0200 From: Markus Schaber To: Oliver Jowett Cc: PostGreSQL JDBC Subject: Re: Avoiding explicit addDataType calls for PostGIS Message-ID: <20041007104603.78af41f3@kingfisher.intern.logi-track.com> In-Reply-To: <41645F7A.2040106@opencloud.com> References: <20041006181653.4fc83924@kingfisher.intern.logi-track.com> <41645F7A.2040106@opencloud.com> Organization: logi-track ag, =?ISO-8859-15?Q?z=FCrich?= X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-pc-linux-gnu) X-Face: Nx5T&>Nj$VrVPv}sC3IL&)TqHHOKCz/|)R$i"*r@w0{*I6w; UNU_hdl1J4NI_m{IMztq=>cmM}1gCLbAF+9\#CGkG8}Y{x%SuQ>1#t:; Z(|\qdd[i]HStki~#w1$TPF}:0w-7"S\Ev|_a$K wrote: > If your objective is to produce a driver that automatically supports > the extra datatypes, how about a provider-properties-file approach? >=20 > i.e. when creating a new connection, the postgresql driver looks for > all resources called postgresql.properties (or whatever) via=20 > ClassLoader.getResources() and reads each in turn. They are > interpreted as properties files, and the resulting properties drive > datatype registration. It could also perhaps be used for other driver=20 > configuration, things like setting the default prepareThreshold etc. > in the absence of URL instructions to the contrary. That is a nice idea that allows to control default configuration without recompiling, and without explicit code in the app. It bites me that I missed that idea... The major advantage would be that, by simply adding the postgis.jar to the class path, the driver would automagically know the appropriate data types - no further config needed. But I wonder how you would handle the case when you have two connections to GIS databases, where you want the first one to map PostGIS geometry to JTS Java Objects, while the second one should produce PostGIS JDBC objects. This example is not as artificial as it sounds, we currently have two independent applications running in the same app server. You will need a connection (rsp. datasource config) specific way to decide which additional datatypes to add. > Perhaps we want to interpret postgresql.=3D identically to a URL=20 > parameter of =3D to make it more general? This is then essentially >=20 > your list-of-datatypes-in-URL approach, with a bit of extra > flexibility so you can easily specify new defaults. Interpreting both URL parameters and properties would solve the conflict problem I mentioned above, as long as one does not rely on the "default" one because the property file read order may be non-deterministic. > PostGIS/JTS can package the basic JDBC driver together with the=20 > appropriate extra datatype classes and a new postgresql.properties. > All users of that driver then get the new datatypes automatically > registered. It is not necessary to mangle the original postgresql.properties. They simply have to put a postgresql.properties in the appropriate path (package) in their own jar. The driver then can use getResources() to get an enumeration of all org/postgres/postgresql.properties that are anywhere in the CLASSPATH, and loop over them to read all additional datatypes. Plug&Play as it was intended. I'm currently not shure, however, whether it's possible to create a deterministic ordering for the ressource enumeration. > You still have the problem that the driver must be able to load the=20 > datatype classes from the driver's classloader, but if you're=20 > repackaging the driver to include extra types, I think that's > acceptable (if you can add a postgresql.properties, you can presumably > add the extra classes too..) I also think that this is a minor problem, as one always can use addDataType() or a Driver wrapper class when needing classes from specific class loaders. > How does that fit with what you need? I think it's a very nice idea, and will definitely make the life easier for most people. And, combined with the URL param =3D properties param approach, we can even handle the above mentioned collision very fine. Maybe we cannot provide all of the flexibility my footnote [2] in the original posting said ("they also allow for other modifications to the connection, e. G. to add prepared statements that are used by most clients etc."), but it would provide the most elegant solution for my original problem. Thanks, Markus Schaber --=20 markus schaber | dipl. informatiker logi-track ag | rennweg 14-16 | ch 8001 z=FCrich phone +41-43-888 62 52 | fax +41-43-888 62 53 mailto:schabios@logi-track.com | www.logi-track.com