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 C955952AC5 for ; Thu, 21 Jul 2005 11:41:08 -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 78984-06 for ; Thu, 21 Jul 2005 14:40:56 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id E26C452824 for ; Thu, 21 Jul 2005 11:40:54 -0300 (ADT) Received: (qmail 9769 invoked from network); 21 Jul 2005 14:40:59 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 21 Jul 2005 14:40:59 -0000 In-Reply-To: <28723.1121946354@www56.gmx.net> References: <28723.1121946354@www56.gmx.net> Mime-Version: 1.0 (Apple Message framework v733) X-Priority: 3 (Normal) Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Message-Id: <24A56AB2-157F-42B6-86E2-2938646BFE3F@fastcrypt.com> Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable From: Dave Cramer Subject: Re: ResultSetMetaData precise typ information Date: Thu, 21 Jul 2005 10:40:58 -0400 To: stefanlack@gmx.de X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/220 X-Sequence-Number: 13368 On 21-Jul-05, at 7:45 AM, stefanlack@gmx.de wrote: > I'm interested in retrieving the most > precise type information as possible from PreparedStatements. > I'm using this driver: 8.1dev-400 JDBC 3 > > 1) ResultSetMetaData.getTableName(int column) is returning "". > Isn't it possible to return the result of getBaseTableName(int =20 > column) in > getTableName, like this > > public abstract class AbstractJdbc2ResultSetMetaData .. { > .. > public String getTableName(int column) throws SQLException > { > //return ""; > return getBaseTableName(column); > } > .. > } You're correct, does anyone know why getTableName is returning "", when getBaseTableName is implemented ? > > 2)Is there a way to determine "length information" for result types in > perpared statements? > > The goal is not to get the length of the actual result after =20 > executing the > query, of course! > Example: > String query =3D "SELECT a, b,c FROM table1,table2; > PreparedStatement stmt =3D getConnection().prepareStatement(query); > ResultSetMetaData data =3D stmt.getMetaData(); > > For bit values > If "a" is a bit(x) column, is it possible to retrieve the value =20 > of x from > the ResultSetMetaData? > Both "data.getScale(index)" and "data.getPrecision(index)" are =20 > returning > "0", not the value expected (e.g. bit(21) -> 21) getPrecision is defined as the number of digits to the left of the =20 decimal, so this should be 1 getScale is defined as the number of digits to the right, this should =20= be 0 > > The same problem holds for character varying(x) This appears to be wrong in the driver, as it is returning 0. > > One could use the > DatabaseMetaData.getTables(...) method. The retrieved ResultSet =20 > contains > many usefull data, > like > this: > rset.getInt("COLUMN_SIZE"),rset.getInt("DECIMAL_DIGITS"),rset.getInt=20= > ("CHAR_OCTET_LENGTH"). > > But I can see no way to identify the query results' columns. In the =20= > example: > - is "a" referencing "table1" or "table2" ? > - In the query "Select a as b from table1;" the > data.getColumnName(index) will return "b", so the true columnname =20 > is not > available. > May it be possible to get a reference to the original column, or =20 > is this > feature not part of of the current jdbc Specification? > > 3) ResultSetMetaData.isNullable(int column) returns not always =20 > expected > information when used for prepared Statements > Example: > > String query =3D "SELECT a, b,c FROM table1 WHERE a notnull and b =20= > notnull > and c notnull > PreparedStatement stmt =3D getConnection().prepareStatement(query); > ResultSetMetaData data =3D stmt.getMetaData(); > > now, data.isNullable(1),data.isNullable(2),data.isNullable(3) are =20 > returning > 1. > I'm aware of the fact that the column "a" is maybe nullable due to =20 > the table > definition, > but clearly in this query a,b,c can never be null values. I'm pretty sure that isNullable(n) refers to the attribute of the =20 table, not the data itself. > > > Thanks, > > Stefan Lack > > --=20 > 5 GB Mailbox, 50 FreeSMS http://www.gmx.net/de/go/promail > +++ GMX - die erste Adresse f=EF=BF=BDr Mail, Message, More +++ > > ---------------------------(end of =20 > broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org > > Dave Cramer davec@postgresintl.com www.postgresintl.com ICQ #14675561 jabber davecramer@jabber.org ph (519 939 0336 )