From: tivvpgsqljdbc@gtech-ua.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: numeric type
Date: Wed, 30 Jul 2008 12:12:20 +0300
Message-ID: <48903074.30207@gtech-ua.com> (raw)
In-Reply-To: <002a01c8f220$8faeec20$af0cc460$@com>
References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com>
<Pine.BSO.4.64.0807290011180.2814@leary.csoft.net>
<001d01c8f14d$cdd715a0$698540e0$@com>
<Pine.BSO.4.64.0807291305500.32353@leary.csoft.net>
<1217366613.5193.11.camel@peter-laptop>
<48902552.6030308@ikoffice.de>
<001701c8f21f$158ab920$40a02b60$@com>
<489028D3.4050706@ikoffice.de>
<002a01c8f220$8faeec20$af0cc460$@com>
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<TP> 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<Connection> {
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.
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-jdbc@postgresql.org
Cc: tivvpgsqljdbc@gtech-ua.com
Subject: Re: numeric type
In-Reply-To: <48903074.30207@gtech-ua.com>
References: <005b01c8ea53$f64a9fd0$e2dfdf70$@com> <Pine.BSO.4.64.0807290011180.2814@leary.csoft.net> <001d01c8f14d$cdd715a0$698540e0$@com> <Pine.BSO.4.64.0807291305500.32353@leary.csoft.net> <1217366613.5193.11.camel@peter-laptop> <48902552.6030308@ikoffice.de> <001701c8f21f$158ab920$40a02b60$@com> <489028D3.4050706@ikoffice.de> <002a01c8f220$8faeec20$af0cc460$@com> <48903074.30207@gtech-ua.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