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 8636D5298B for ; Wed, 3 Aug 2005 13:36:55 -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 10033-03 for ; Wed, 3 Aug 2005 16:36:48 +0000 (GMT) Received: from helios.lunarpages.com (helios.lunarpages.com [216.193.217.209]) by svr1.postgresql.org (Postfix) with ESMTP id 1A54952932 for ; Wed, 3 Aug 2005 13:36:46 -0300 (ADT) Received: from dsl-201-129-232-126.prod-infinitum.com.mx ([201.129.232.126] helo=vpj.e-evolution.com) by helios.lunarpages.com with esmtpa (Exim 4.50) id 1E0MEV-0005SL-7j; Wed, 03 Aug 2005 09:36:43 -0700 From: =?iso-8859-1?q?V=EDctor_P=E9rez_Ju=E1rez?= Organization: e-Evolution To: pgsql-jdbc@postgresql.org Subject: Re: some improve JDBC Date: Wed, 3 Aug 2005 12:20:16 -0500 User-Agent: KMail/1.8 Cc: Oliver Jowett References: <200508021235.03510.victor.perez@e-evolution.com.mx> <42F007EB.9020204@opencloud.com> In-Reply-To: <42F007EB.9020204@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200508031220.16657.victor.perez@e-evolution.com.mx> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - helios.lunarpages.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - e-evolution.com.mx X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.089 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_IN_NJABL_PROXY X-Spam-Level: * X-Archive-Number: 200508/24 X-Sequence-Number: 13593 Of cosure! my changes are commnet with e-evolution =A0 =A0 =A0 =A0 //begin vpj-cd e-evolution =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (type_name.equals( "text") || type_name.equals("bytea")) =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 =A0 =A0 if (typmod =3D=3D -1) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return typmod;=20 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (type_name.equals( "unknown")) =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //end vpj-cd e-evolution // being vpj-cd e-evolution 07/30/2005 =A0 =A0 =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 =A0 =A0 if (typmod < 0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return typmod; // VARHDRSZ=3Dsizeof(int32)= =3D4 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 // end vpj-cd e-evolution 07/30/2005 =2D------------------------------------------------------------------------= =2D------------------------------------------------------------- the code complete: /* =A0 =A0 =A0* What is the column's normal maximum width in characters? =A0 =A0 =A0* =A0 =A0 =A0* @param column the first column is 1, the second is 2, etc. =A0 =A0 =A0* @return the maximum width =A0 =A0 =A0* @exception SQLException if a database access error occurs =A0 =A0 =A0*/ =A0 =A0=20 =A0 =A0 public int getColumnDisplaySize(int column) throws SQLException =A0 =A0 { =A0 =A0 =A0 =A0 Field f =3D getField(column); =A0 =A0 =A0 =A0 String type_name =3D getPGType(column); =A0 =A0 =A0 =A0 int typmod =3D f.getMod(); =A0 =A0 =A0 =A0 // I looked at other JDBC implementations and couldn't find= a=20 consistent =A0 =A0 =A0 =A0 // interpretation of the "display size" for numeric values,= so this is=20 our's =A0 =A0 =A0 =A0 // FIXME: currently, only types with a SQL92 or SQL3 pendan= t are=20 implemented - jens@jens.de =A0 =A0 =A0 =A0 // fixed length data types =A0 =A0 =A0 =A0 if (type_name.equals( "int2" )) =A0 =A0 =A0 =A0 =A0 =A0 return 6; =A0// -32768 to +32768 (5 digits and a si= gn) =A0 =A0 =A0 =A0 if (type_name.equals( "int4" ) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 || type_name.equals( "oid" )) =A0 =A0 =A0 =A0 =A0 =A0 return 11; // -2147483648 to +2147483647 =A0 =A0 =A0 =A0 if (type_name.equals( "int8" )) =A0 =A0 =A0 =A0 =A0 =A0 return 20; // -9223372036854775808 to +922337203685= 4775807 =A0 =A0 =A0 =A0 if (type_name.equals( "money" )) =A0 =A0 =A0 =A0 =A0 =A0 return 12; // MONEY =3D DECIMAL(9,2) =A0 =A0 =A0 =A0 if (type_name.equals( "float4" )) =A0 =A0 =A0 =A0 =A0 =A0 return 11; // i checked it out ans wasn't able to p= roduce more=20 than 11 digits =A0 =A0 =A0 =A0 if (type_name.equals( "float8" )) =A0 =A0 =A0 =A0 =A0 =A0 return 20; // dito, 20 =A0 =A0 =A0 =A0 if (type_name.equals( "char" )) =A0 =A0 =A0 =A0 =A0 =A0 return 1; =A0 =A0 =A0 =A0 if (type_name.equals( "bool" )) =A0 =A0 =A0 =A0 =A0 =A0 return 1; =A0 =A0 =A0 =A0 int secondSize; =A0 =A0 =A0 =A0 switch (typmod) =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 case 0: =A0 =A0 =A0 =A0 =A0 =A0 secondSize =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 break; =A0 =A0 =A0 =A0 case - 1: =A0 =A0 =A0 =A0 =A0 =A0 // six digits plus the decimal point =A0 =A0 =A0 =A0 =A0 =A0 secondSize =3D 7; =A0 =A0 =A0 =A0 =A0 =A0 break; =A0 =A0 =A0 =A0 default: =A0 =A0 =A0 =A0 =A0 =A0 // with an odd scale an even number of digits =A0 =A0 =A0 =A0 =A0 =A0 // are always show so timestamp(1) will print =A0 =A0 =A0 =A0 =A0 =A0 // two fractional digits. =A0 =A0 =A0 =A0 =A0 =A0 secondSize =3D typmod + (typmod % 2) + 1; =A0 =A0 =A0 =A0 =A0 =A0 break; =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 if (type_name.equals( "date" )) =A0 =A0 =A0 =A0 =A0 =A0 return 13; // "01/01/4713 BC" - "31/12/32767" =A0 =A0 =A0 =A0 // If we knew the timezone we could avoid having to possibly =A0 =A0 =A0 =A0 // account for fractional hour offsets (which adds three ch= ars). =A0 =A0 =A0 =A0 // =A0 =A0 =A0 =A0 // Also the range of timestamp types is not exactly clear. =A0 =A0 =A0 =A0 // 4 digits is the common case for a year, but there are =A0 =A0 =A0 =A0 // version/compilation dependencies on the exact date range= s, =A0 =A0 =A0 =A0 // (notably --enable-integer-datetimes), but for now we'll =A0 =A0 =A0 =A0 // just ignore them and assume that a year is four digits. =A0 =A0 =A0 =A0 // =A0 =A0 =A0 =A0 if (type_name.equals( "time" )) =A0 =A0 =A0 =A0 =A0 =A0 return 8 + secondSize; =A0// 00:00:00 + seconds =A0 =A0 =A0 =A0 if (type_name.equals( "timetz" )) =A0 =A0 =A0 =A0 =A0 =A0 return 8 + secondSize + 6; // 00:00.00 + .000000 + = =2D00:00 =A0 =A0 =A0 =A0 if (type_name.equals( "timestamp" )) =A0 =A0 =A0 =A0 =A0 =A0 return 19 + secondSize; // 0000-00-00 00:00:00 + .0= 00000; =A0 =A0 =A0 =A0 if (type_name.equals( "timestamptz" )) =A0 =A0 =A0 =A0 =A0 =A0 return 19 + secondSize + 6; // 0000-00-00 00:00:00 = + .000000 +=20 =2D00:00; =A0 =A0 =A0 =A0 //begin vpj-cd e-evolution =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (type_name.equals( "text") || type_name.equals("bytea")) =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 =A0 =A0 if (typmod =3D=3D -1) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return typmod;=20 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (type_name.equals( "unknown")) =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 //end vpj-cd e-evolution =A0 =A0 =A0 =A0=20 =A0 =A0 =A0 =A0 // variable length fields =A0 =A0 =A0 =A0 typmod -=3D 4; =A0 =A0 =A0 =A0 if (type_name.equals( "bpchar" ) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 || type_name.equals( "varchar" )) =A0 =A0 =A0 =A0 // being vpj-cd e-evolution 07/30/2005 =A0 =A0 =A0 =A0 =A0 =A0 { =A0 =A0 =A0 =A0 =A0 =A0 if (typmod < 0) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return typmod; // VARHDRSZ=3Dsizeof(int32)= =3D4 =A0 =A0 =A0 =A0 } =A0 =A0 =A0 =A0 // end vpj-cd e-evolution 07/30/2005 =A0 =A0 =A0 =A0 =A0 =A0=20 =A0 =A0 =A0 =A0 if (type_name.equals( "numeric" )) =A0=A0=A0=A0=A0=A0=A0=A0{ =A0 =A0 =A0 =A0 =A0 =A0 //return ( (typmod >> 16) & 0xffff ) =A0 =A0 =A0 =A0 =A0 =A0 // =A0 =A0 =A0 + 1 + ( typmod & 0xffff ); // DECIMA= L(p,s) =3D (p digits). (s digits) =A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0if( ((typmod >> 16) & 0xffff ) =A0+ 1 + ( t= ypmod & 0xffff ) =3D=3D -1) =A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 return 0; =A0 =A0 =A0 =A0 =A0 =A0 else =A0 =A0 =A0 =A0 =A0 =A0 return ( (typmod >> 16) & 0xffff ) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+ 1 + ( typmod & 0xffff );=A0=A0=A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A0=A0=A0=A0=A0=A0} =A0 =A0 =A0 =A0 // if we don't know better =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return f.getLength(); =A0 =A0 =A0 =A0 =A0 =A0 =A0=20 =A0 =A0 } * =A0JDBC driver build number =A0=A0=A0=A0=A0=A0=A0=A08.1dev-401 JDBC Source =A0 =A0 * Server version =A0 =A0 =A0 =A0PostgreSQL 8.0.3 in Linux AMD64 Cheers Victor P=E9rez CEO e-Evolution,SC www.e-evolution.com El Martes, 2 de Agosto de 2005 18:55, Oliver Jowett escribi=F3: > V=EDctor P=E9rez Ju=E1rez wrote: > > Compiere use the RowSet implementation, I made some changes to the sou= rce > > AbstractJdbc2ResultSetMetaData method: > > Can you send a diff? I can't see what you've changed from just this. > > -O > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq