Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B6BFB64FF8A for ; Wed, 30 Jul 2008 06:12:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 85638-08-3 for ; Wed, 30 Jul 2008 06:12:23 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.zoral.com.ua (skuns.zoral.com.ua [91.193.166.194]) by postgresql.org (Postfix) with ESMTP id E6FF76501C6 for ; Wed, 30 Jul 2008 06:12:25 -0300 (ADT) Received: from [10.1.1.57] (tivv.kiev.zoral.com.ua [10.1.1.57]) (authenticated bits=0) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m6U9CK9i086619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 30 Jul 2008 12:12:21 +0300 (EEST) (envelope-from tivvpgsqljdbc@gtech-ua.com) Message-ID: <48903074.30207@gtech-ua.com> Date: Wed, 30 Jul 2008 12:12:20 +0300 From: tivvpgsqljdbc@gtech-ua.com User-Agent: Thunderbird 2.0.0.14 (X11/20080421) MIME-Version: 1.0 CC: pgsql-jdbc@postgresql.org Subject: Re: numeric type References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> <001d01c8f14d$cdd715a0$698540e0$@com> <1217366613.5193.11.camel@peter-laptop> <48902552.6030308@ikoffice.de> <001701c8f21f$158ab920$40a02b60$@com> <489028D3.4050706@ikoffice.de> <002a01c8f220$8faeec20$af0cc460$@com> In-Reply-To: <002a01c8f220$8faeec20$af0cc460$@com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=4.777 tagged_above=0 required=5 tests=FROM_LOCAL_NOVOWEL=3.196, MISSING_HEADERS=1.581 X-Spam-Level: **** X-Archive-Number: 200807/71 X-Sequence-Number: 18856 Peter написав(ла): >>> Long story. We're migrating old Access app to Postgres but still need >>> to be able to exchange datasets with the old app users (app supports >>> it's own import/export in MDB format). Since migration is expected to >>> last several years we need some sort of automated PG->MDB thing. >>> >>> >> Why don't you just make you converter configurable on how it handles >> decimal without specs? >> > > I would need to hack Jackcess library in order to do that... besides it does > not seem the proper way to do it, more like an ugly hack. getPrecision and > getScale are supposed to return the true precision and scale after all... > > Peter > > It may be easier to write a wrapper over JDBC driver doing needed conversion. With Java Proxy it is not a complex task. It may look much like the next: public class DelegatingHandler implements InvocationHandler { protected final TP parent; public DelegatingHandler(TP parent) { this.parent = parent; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Method override = this.getClass().getMethod(method.getName(), method.getParameterTypes()); if (override != null) return override.invoke(this, args); return method.invoke(parent, args); } } public class ConnectionWrapper extends DelegatingHandler { public static Connection makeConnectionWrapper(Connection connection) { return (Connection) Proxy.newProxyInstance(ConnectionWrapper.class.getClassLoader(), new Class[]{Connection.class}, new ConnectionWrapper(connection)); } ... public PreparedStatement prepareStatement(String sql) throws SQLException { return makePreparedStatementWrapper(parent.prepareStatement(sql)); } ... } You simply create a wrapper and "override" needed methods by making methods in wrapper with exactly same name and signature, calling parent instead of super when needed.