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 28C5652E99 for ; Tue, 2 Aug 2005 13:53:46 -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 49753-06 for ; Tue, 2 Aug 2005 16:53:43 +0000 (GMT) Received: from helios.lunarpages.com (helios.lunarpages.com [216.193.217.209]) by svr1.postgresql.org (Postfix) with ESMTP id 4C0EC52E84 for ; Tue, 2 Aug 2005 13:53:42 -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 1E001M-0000Rp-Jy for pgsql-jdbc@postgresql.org; Tue, 02 Aug 2005 09:53:41 -0700 From: =?iso-8859-1?q?V=EDctor_P=E9rez_Ju=E1rez?= Organization: e-Evolution To: pgsql-jdbc@postgresql.org Subject: some improve JDBC Date: Tue, 2 Aug 2005 12:34:59 -0500 User-Agent: KMail/1.8 MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <200508021235.03510.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.102 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_IN_NJABL_PROXY X-Spam-Level: * X-Archive-Number: 200508/12 X-Sequence-Number: 13581 Hi all! My name is Victor, I lead the enterprise www.e-evolution.com, we are workin= g=20 in making a port of software Compiere (www.compiere.org) that now only work= s=20 with oracle to PostgreSQL. Compiere use the RowSet implementation, I made some changes to the source=20 AbstractJdbc2ResultSetMetaData method: /* * What is the column's normal maximum width in characters? * * @param column the first column is 1, the second is 2, etc. * @return the maximum width * @exception SQLException if a database access error occurs */ =20 public int getColumnDisplaySize(int column) throws SQLException { Field f =3D getField(column); String type_name =3D getPGType(column); int typmod =3D f.getMod(); // I looked at other JDBC implementations and couldn't find a=20 consistent // interpretation of the "display size" for numeric values, so this= is=20 our's // FIXME: currently, only types with a SQL92 or SQL3 pendant are=20 implemented - jens@jens.de // fixed length data types if (type_name.equals( "int2" )) return 6; // -32768 to +32768 (5 digits and a sign) if (type_name.equals( "int4" ) || type_name.equals( "oid" )) return 11; // -2147483648 to +2147483647 if (type_name.equals( "int8" )) return 20; // -9223372036854775808 to +9223372036854775807 if (type_name.equals( "money" )) return 12; // MONEY =3D DECIMAL(9,2) if (type_name.equals( "float4" )) return 11; // i checked it out ans wasn't able to produce more= =20 than 11 digits if (type_name.equals( "float8" )) return 20; // dito, 20 if (type_name.equals( "char" )) return 1; if (type_name.equals( "bool" )) return 1; int secondSize; switch (typmod) { case 0: secondSize =3D 0; break; case - 1: // six digits plus the decimal point secondSize =3D 7; break; default: // with an odd scale an even number of digits // are always show so timestamp(1) will print // two fractional digits. secondSize =3D typmod + (typmod % 2) + 1; break; } if (type_name.equals( "date" )) return 13; // "01/01/4713 BC" - "31/12/32767" // If we knew the timezone we could avoid having to possibly // account for fractional hour offsets (which adds three chars). // // Also the range of timestamp types is not exactly clear. // 4 digits is the common case for a year, but there are // version/compilation dependencies on the exact date ranges, // (notably --enable-integer-datetimes), but for now we'll // just ignore them and assume that a year is four digits. // if (type_name.equals( "time" )) return 8 + secondSize; // 00:00:00 + seconds if (type_name.equals( "timetz" )) return 8 + secondSize + 6; // 00:00.00 + .000000 + -00:00 if (type_name.equals( "timestamp" )) return 19 + secondSize; // 0000-00-00 00:00:00 + .000000; if (type_name.equals( "timestamptz" )) return 19 + secondSize + 6; // 0000-00-00 00:00:00 + .000000 += =20 =2D00:00; //begin vpj-cd e-evolution =20 if (type_name.equals( "text") || type_name.equals("bytea")) { if (typmod =3D=3D -1) return 0; else return typmod;=20 } =20 if (type_name.equals( "unknown")) return 0; =20 //end vpj-cd e-evolution =20 // variable length fields typmod -=3D 4; if (type_name.equals( "bpchar" ) || type_name.equals( "varchar" )) // being vpj-cd e-evolution 07/30/2005 =20 { if (typmod < 0) return 0; else return typmod; // VARHDRSZ=3Dsizeof(int32)=3D4 } // end vpj-cd e-evolution 07/30/2005 =20 if (type_name.equals( "numeric" )) { //return ( (typmod >> 16) & 0xffff ) // + 1 + ( typmod & 0xffff ); // DECIMAL(p,s) =3D (p digi= ts). (s digits) if( ((typmod >> 16) & 0xffff ) + 1 + ( typmod & 0xffff ) =3D=3D -1) return 0; else return ( (typmod >> 16) & 0xffff ) + 1 + ( typmod & 0xffff ); =20 } // if we don't know better =20 return f.getLength(); =20 } * JDBC driver build number 8.1dev-401 JDBC Source * Server version PostgreSQL 8.0.3 in Linux AMD64 Cheers Victor P=E9rez CEO e-Evolution,SC www.e-evolution.com