pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Custom types in Postgres, JDBC
2+ messages / 2 participants
[nested] [flat]

* Custom types in Postgres, JDBC
@ 2005-07-20 20:52  Christian Cryder <c.s.cryder@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Christian Cryder @ 2005-07-20 20:52 UTC (permalink / raw)
  To: 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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Custom types in Postgres, JDBC
@ 2005-07-20 22:04  Dave Cramer <pg@fastcrypt.com>
  parent: Christian Cryder <c.s.cryder@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Cramer @ 2005-07-20 22:04 UTC (permalink / raw)
  To: Christian Cryder <c.s.cryder@gmail.com>; +Cc: pgsql-jdbc


On 20-Jul-05, at 4:52 PM, Christian Cryder wrote:

> 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.

also look at http://joda-time.sourceforge.net/
for an implementation of date/time for java that might be better
>
> 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.
have a look at this

http://www.postgresql.org/docs/8.0/interactive/sql-createtype.html


>
> Any thoughts on whether this is a good idea or a bad one? Any  
> pointers? Caveats?
>
> Thanks,
> Christian
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
>        subscribe-nomail command to majordomo@postgresql.org so that  
> your
>        message can get through to the mailing list cleanly
>
>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-07-20 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-20 20:52 Custom types in Postgres, JDBC Christian Cryder <c.s.cryder@gmail.com>
2005-07-20 22:04 ` Dave Cramer <pg@fastcrypt.com>

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