Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 859E22E015A for ; Sun, 2 Dec 2007 05:25:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 64567-05 for ; Sun, 2 Dec 2007 05:25:44 -0400 (AST) Received: from live.cleverthinking.co.uk (server217-174-252-150.live-servers.net [217.174.252.150]) by postgresql.org (Postfix) with ESMTP id C5B282E0159 for ; Sun, 2 Dec 2007 05:25:44 -0400 (AST) Received: from fh1 ([217.174.252.150]) by live.cleverthinking.co.uk (JAMES SMTP Server 2.3.0) with SMTP ID 74 for ; Sun, 2 Dec 2007 09:25:37 +0000 (GMT) Message-ID: <475279DC.8050109@primetext.com> Date: Sun, 02 Dec 2007 09:24:44 +0000 From: Roy Smith User-Agent: Thunderbird 2.0.0.0 (X11/20070419) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: "create type" custom types not supported by JDBC References: <475112C4.9060403@primetext.com> <13658722.71591196500766061.JavaMail.root@fh1> In-Reply-To: <13658722.71591196500766061.JavaMail.root@fh1> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/10 X-Sequence-Number: 17865 Thanks for the pointer Kris. It's now working. For the sake of anybody trying the same, here's what I did ... In the database:- create type couk_cleverthinking_gwappo_db_Money as (local_value numeric(11,2),mnemonic char(3), exchange_rate numeric(9,5),base_value numeric(11,2)); CREATE TABLE prices (price couk_cleverthinking_gwappo_db_Money); insert into prices values(ROW(100,'PHP',.943,0.94)); select * from prices; price ---------------------- (100.00,PHP,0.943,0.94) My Custom class is:- public class Money extends PGobject implements SQLData, Serializable{ public Money() { setType("couk_cleverthinking_gwappo_db_money"); } public Money(String _value) { setType("couk_cleverthinking_gwappo_db_money"); ... stuff ... } ... stuff ... } To use it I do :- Connection conn = DriverManager.getConnection(url, userName, password); ((PGConnection) conn).addDataType("couk_cleverthinking_gwappo_db_money",Class.forName("couk.cleverthinking.gwappo.db.Money")); Money m2 = new Money("(100,USD,0.534,0.53)"); PreparedStatement pst; pst = conn.prepareStatement("insert into prices values(?)"); pst.setObject(1,m2); I do have a follow up question about how this might all work in a JPA layer (Oracle Toplink). That's another post :-) Many thanks Kris Jurka wrote: > On Sat, 1 Dec 2007, Kris Jurka wrote: >>> Poking around the source code of AbstractJdbc2Connection it looks >>> like this functionality isn't support. Perhaps an "Unsupported >>> feature" error would be more helpful than a ClassCastException. > I've put a fix for this into CVS.