X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3F017529E2 for ; Wed, 20 Jul 2005 19:04:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76732-01 for ; Wed, 20 Jul 2005 22:04:54 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 35195529A3 for ; Wed, 20 Jul 2005 19:04:53 -0300 (ADT) Received: (qmail 31520 invoked from network); 20 Jul 2005 22:04:55 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 20 Jul 2005 22:04:55 -0000 In-Reply-To: <90876a9e05072013521b8d8e98@mail.gmail.com> References: <90876a9e05072013521b8d8e98@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: List Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Custom types in Postgres, JDBC Date: Wed, 20 Jul 2005 18:04:54 -0400 To: Christian Cryder X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/202 X-Sequence-Number: 13350 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 > >