Skip site navigation (1) Skip section navigation (2)

Re: "create type" custom types not supported by JDBC

From: Roy Smith <roy(dot)smith(at)primetext(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: "create type" custom types not supported by JDBC
Date: 2007-12-02 09:24:44
Message-ID: (view raw or whole thread)
Lists: pgsql-jdbc
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 
CREATE TABLE prices (price couk_cleverthinking_gwappo_db_Money);
insert into prices values(ROW(100,'PHP',.943,0.94));
select * from prices;

My Custom class is:-
public class Money extends PGobject implements SQLData, Serializable{
    public Money() {
    public Money(String _value) {
    ... stuff ...
... stuff ...

To use it I do :-
            Connection conn = DriverManager.getConnection(url, userName, 
            Money m2 = new Money("(100,USD,0.534,0.53)");
            PreparedStatement pst;
            pst = conn.prepareStatement("insert into prices values(?)");

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.

In response to

pgsql-jdbc by date

Next:From: Christian KindlerDate: 2007-12-03 18:35:50
Subject: Re: prepared statement using postgres array
Previous:From: Kris JurkaDate: 2007-12-02 06:51:05
Subject: Re: OID Bug in

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group