Received: from mail0.epfl.ch (mail0.epfl.ch [128.178.50.57]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f168sSx55033 for ; Tue, 6 Feb 2001 03:54:28 -0500 (EST) (envelope-from Philippe.Rochat@epfl.ch) Received: (qmail 11613 invoked from network); 6 Feb 2001 08:54:26 -0000 Received: from lbdpc11.epfl.ch (HELO lbdpc11) (128.178.77.43) by mail0.epfl.ch with SMTP; 6 Feb 2001 08:54:26 -0000 From: "Philippe Rochat" To: Subject: Date: Tue, 6 Feb 2001 09:54:25 +0100 Message-ID: <000f01c0901a$6831d6a0$2b4db280@lbdpc11> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0010_01C09022.C9F63EA0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal X-Archive-Number: 200102/45 X-Sequence-Number: 645 This is a multi-part message in MIME format. ------=_NextPart_000_0010_01C09022.C9F63EA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Attached is a modified version of Field.java for the JDBC driver. I think types were not so correctly defined, and that this version should be more well suiting last version of postgres. Any comment welcome, Ph.R. BTW: author e-mail in the README of jdbc in the distrib does not exist anymore ... ! _____________________________________________________________________ Philippe Rochat, (Yahoo-id:philipperochat) EPFL DI-LBD Database Laboratory CH-1015 LAUSANNE Swiss Federal Institute of Technology (EPFL) tel:++41 21 693 52 53 Beep-EPFL: 181 4644 fax:++41 21 693 51 95 Private: Grammont, 9 1007 LAUSANNE tel:++41 21 617 03 05 mailto:Philippe.Rochat@epfl.ch GSM:++41 76 384 52 53 ------=_NextPart_000_0010_01C09022.C9F63EA0 Content-Type: application/octet-stream; name="Field.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Field.java" package org.postgresql; import java.lang.*; import java.sql.*; import java.util.*; import org.postgresql.*; import org.postgresql.util.*; /** * org.postgresql.Field is a class used to describe fields in a PostgreSQL * ResultSet */ public class Field { public int length; // Internal Length of this field public int oid; // OID of the type public int mod; // type modifier of this field public String name; // Name of this field =20=20 protected Connection conn; // Connection Instantation =20=20 public int sql_type =3D -1; // The entry in java.sql.Types for this field public String type_name =3D null;// The sql type name =20=20 /** * Construct a field based on the information fed to it. * * @param conn the connection this field came from * @param name the name of the field * @param oid the OID of the field * @param len the length of the field */ public Field(Connection conn, String name, int oid, int length,int mod) { this.conn =3D conn; this.name =3D name; this.oid =3D oid; this.length =3D length; this.mod =3D mod; } =20=20 /** * Constructor without mod parameter. * * @param conn the connection this field came from * @param name the name of the field * @param oid the OID of the field * @param len the length of the field */ public Field(Connection conn, String name, int oid, int length) { this(conn,name,oid,length,0); } =20=20=20=20 /** * @return the oid of this Field's data type */ public int getOID() { return oid; } =20=20 /** * the ResultSet and ResultMetaData both need to handle the SQL * type, which is gained from another query. Note that we cannot * use getObject() in this, since getObject uses getSQLType(). * * @return the entry in Types that refers to this field * @exception SQLException if a database access error occurs */ public int getSQLType() throws SQLException { if(sql_type =3D=3D -1) { type_name =3D (String)conn.fieldCache.get(new Integer(oid)); =20=20=20=20=20=20 // it's not in the cache, so perform a query, and add the result to // the cache if(type_name=3D=3Dnull) { ResultSet result =3D (org.postgresql.ResultSet)conn.ExecSQL("select typnam= e from pg_type where oid =3D " + oid); if (result.getColumnCount() !=3D 1 || result.getTupleCount() !=3D 1) throw new PSQLException("postgresql.unexpected"); result.next(); type_name =3D result.getString(1); conn.fieldCache.put(new Integer(oid),type_name); result.close(); } =20=20=20=20=20=20 sql_type =3D getSQLType(type_name); } return sql_type; } =20=20 /** * This returns the SQL type. It is called by the Field and DatabaseMetaD= ata classes * @param type_name PostgreSQL type name * @return java.sql.Types value for oid */ public static int getSQLType(String type_name) { int sql_type =3D Types.OTHER; // default value for(int i=3D0;i