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 97D92D1B1F8 for ; Tue, 6 Jul 2004 17:23:06 -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 53558-07 for ; Tue, 6 Jul 2004 20:22:59 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 5CE89D1B1DA for ; Tue, 6 Jul 2004 17:22:56 -0300 (ADT) Received: (qmail 26179 invoked from network); 6 Jul 2004 20:22:53 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 6 Jul 2004 20:22:54 -0000 Subject: Re: getXXX methods From: Dave Cramer Reply-To: pg@fastcrypt.com To: Kris Jurka Cc: "pgsql-jdbc@postgresql.org" In-Reply-To: References: <1088795907.1536.118.camel@localhost.localdomain> Content-Type: text/plain Organization: Cramer Consulting Message-Id: <1089145387.1506.65.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 06 Jul 2004 16:23:07 -0400 Content-Transfer-Encoding: 7bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/40 X-Sequence-Number: 10424 Once possibility is to use Double.parseDouble(s).byteValue() so the code would become try { Byte.parseByte(s) } catch(NumberFormatException e) { try { return Double.parseDouble(s).ByteValue(); } catch( NumberFormatException ne ) { throw exception; } } Dave On Tue, 2004-07-06 at 14:46, Kris Jurka wrote: > On Fri, 2 Jul 2004, Dave Cramer wrote: > > > There is a table in the jdbc spec which suggests that > > there is a preferred method for getting the column information, and at > > non-preferred method. > > > > would all the numeric values be truncated ? > > > > What do we do with char, varchar, longvarchar ? > > It's tough to say. Looking at the current situation for retrieving double > values with getInt() the current driver will throw an Exception on a out > of range value because it starts with a String and uses Integer.parseInt() > on it. Contrast this with the result of > > Double d = new Double(Double.MAX_VALUE); > System.out.println(d.intValue()); > > which truncates the double to Integer.MAX_VALUE. The javadocs are > useless, but I prefer the Exception to silent truncation, so I would > suggest getByte can be used on any integer value of -128 to 127 regardless > of its storage form (like text). The question of comparing floating point > numbers should be the same, but we may run into problems when 1 is > represented as 1.00000001. > > Kris Jurka > > > > !DSPAM:40eaf9e7148133410918667! > > -- Dave Cramer 519 939 0336 ICQ # 14675561