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 D2369D1B248 for ; Sun, 11 Jul 2004 17:55:17 -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 60210-07 for ; Sun, 11 Jul 2004 20:55:15 +0000 (GMT) Received: from ms-smtp-03.rdc-kc.rr.com (ms-smtp-03.rdc-kc.rr.com [24.94.166.129]) by svr1.postgresql.org (Postfix) with ESMTP id A3A2DD1B25F for ; Sun, 11 Jul 2004 17:55:11 -0300 (ADT) Received: from mdirect.markhamdirect.com (CPE-24-160-241-48.wi.rr.com [24.160.241.48]) by ms-smtp-03.rdc-kc.rr.com (8.12.10/8.12.7) with ESMTP id i6BKscjE006861; Sun, 11 Jul 2004 15:54:38 -0500 (CDT) Received: by mdirect.markhamdirect.com (Postfix, from userid 99) id B2671239C3; Sun, 11 Jul 2004 15:55:41 -0500 (CDT) Received: from [127.0.0.1] (unknown [192.168.1.100]) by mdirect.markhamdirect.com (Postfix) with ESMTP id 53AE2234D0; Sun, 11 Jul 2004 15:55:34 -0500 (CDT) Message-ID: <40F1A903.9040000@markhamdirect.com> Date: Sun, 11 Jul 2004 15:54:27 -0500 From: Greg Markham User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Oliver Jowett Cc: pgsql-jdbc@postgresql.org Subject: Re: Timestamp Question References: <40F012E4.3000001@markhamdirect.com> <40F15284.2090905@opencloud.com> In-Reply-To: <40F15284.2090905@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/97 X-Sequence-Number: 10481 Oliver Jowett wrote: > Greg Markham wrote: > >> I have searched the archives and not found and answer to this question: >> >> I am trying to use a Java Timestamp object to create a Postgresql >> Timestamp(6) field. I can insert a Timestamp but it only goes to the >> millisecond(2004-07-10 12:59:59.123) I need it to the microsecond >> (2004-07-10 12:59:59.123456). Is there a way to do this? > > > From a quick look at the driver code, it appears to support nanosecond > precision in Timestamps. > > What exactly is the problem you see? Can you provide a testcase? > > -O > Timestamp myTs = new Timestamp(System.currentTimeMillis()); PreparedStatement myStatement = con.prepareStatement("insert into mytable (myID, myTimestamp) values (?,?)); myStatement.setString(1, "4451234578521"); myStatement.setTimestamp(2, myTs); myStatement.execute(); Data that get inserted is: 4451234578521 2004-07-11 15:34:26.234 When I create a timestamp using the system.currentTimeMillis it just doesn't create a timestamp that has the precision I want. I want the timestamp out past the millisecond and out to the microsecond like 2004-07-11 15:34:26.274123. How would I use the timestamp object to get to that precision? Do I have to use a JNI call? - Greg Markham