Custom types in Postgres, JDBC

From: Christian Cryder <c(dot)s(dot)cryder(at)gmail(dot)com>
To: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Custom types in Postgres, JDBC
Date: 2005-07-20 20:52:21
Message-ID: 90876a9e05072013521b8d8e98@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Here's a question. Let's say I wanted to create a custom datatype in
Postrgres - something like a timezone2 which would persist the data as
millis. Does anyone have any pointers on where one would start in
thinking about this?

I am pretty sure that I could implement something in our statement
wrapper classes that would allow me to convert timestamps to millis
values and then save them as bigints rather than timestamps. And I
could probably create a couple of stored proc functions on the server
for easily displaying such millis as timestamps, and querying against
them via a timestamp string.

So I guess what I am asking is - how would one actually do it at a
lower level - defining a new type within postgres, and then having
that mapped to a new custom type (which my wrapper classes could then
convert to java.sql.Timestamps). I realize this is more than just a
JDBC question, but JDBC certainly plays a role in it.

Any thoughts on whether this is a good idea or a bad one? Any pointers? Caveats?

Thanks,
Christian

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2005-07-20 20:56:42 Re: Timestamp Conversion Woes Redux
Previous Message Christian Cryder 2005-07-20 20:44:37 Re: Timestamp Conversion Woes Redux