Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A3B23B5DBC0 for ; Fri, 30 Sep 2011 03:19:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 21954-06 for ; Fri, 30 Sep 2011 06:19:00 +0000 (UTC) X-Greylist: delayed 00:05:11.261123 by SQLgrey-1.8.0-rc2 Received: from dub0-omc3-s4.dub0.hotmail.com (dub0-omc3-s4.dub0.hotmail.com [157.55.2.13]) by mail.postgresql.org (Postfix) with ESMTP id EA16EB5D801 for ; Fri, 30 Sep 2011 03:18:59 -0300 (ADT) Received: from DUB114-W45 ([157.55.2.7]) by dub0-omc3-s4.dub0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 29 Sep 2011 23:13:48 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_97be8a6b-13fc-4894-96f8-16b430f9ea32_" X-Originating-IP: [57.66.141.2] From: Thomas Strunz To: Subject: metadata.getColumns() using Apache Tomcat / jndi Date: Fri, 30 Sep 2011 08:13:47 +0200 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 30 Sep 2011 06:13:48.0117 (UTC) FILETIME=[1DC3D050:01CC7F38] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201109/131 X-Sequence-Number: 22249 --_97be8a6b-13fc-4894-96f8-16b430f9ea32_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all=2C issue affects 9.1-901.jdbc4 and 9.0-801.jdbc4 driver. i have following java code:
            Connection conn =3D dataSource.getConnection()=3B
            DatabaseMetaData metaData =3D conn.getMetaData()=3B
            this.databaseProductName =3D metaData.getDatabaseProductName()=
=3B
            ResultSet rsColumns =3D metaData.getColumns(
                    null=2C null=2C tableName=2C null)=3B
            while (rsColumns.next()) {
                //..do work
            }
            rsColumns.close()=3B
            conn.close()=3B
This works fine when initializing the PostgreSQL DataSoource manually as in= :
        PGSimpleDataSource dataSource =3D new PGSimpleDataSource()=3B
        dataSource.setDatabaseName(postgresqlDatabaseName)=3B
        dataSource.setServerName(postgresqlHost)=3B
        dataSource.setUser(postgresqlUser)=3B
        dataSource.setPassword(postgresqlPW)=3B
        return dataSource=3B
If I want to get the datasource from jndi / tomcat as in: the result set returned by metaData.getColumns(null=2C null=2C tableName=2C= null) is always empty. However if I use MySQL=2C SQL Server or HSQLDB the code also works in tomca= t eg. works perfectly fine and metaData.getColumns returns exactly what I would e= xpect. My table name only contains letters and is all lower case (postgresql jdbc = is IMHO a bit quirky since table and field names seem to be partially case-= sensitive). Any ideas? Bug? the problem does seem to be a postgresql issue (and not tom= cat) because code works fine for other JDBC Drivers. Thanks for your help. = --_97be8a6b-13fc-4894-96f8-16b430f9ea32_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all=2C

issue affects 9.1-901.jdbc4 =3B and 9.0-801.jdbc4 driv= er.

i have following java code:

<=3Bpre>=3B
 =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B Connection conn =3D dataSource.getConnection()=3B
 =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B Data= baseMetaData metaData =3D conn.getMetaData()=3B
 =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B this.datab= aseProductName =3D metaData.getDatabaseProductName()=3B
 =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B Re= sultSet rsColumns =3D metaData.getColumns(
 =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B null=2C null=2C tableName= =2C null)=3B
 =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B while (rsColumns.next()) {
 =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B //..do work
 =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B }
 =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B rsColumns.close()=3B
 =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B conn.close()=3B
<=3B/pre&g= t=3B

This works fine when initializing the PostgreSQL DataSoource ma= nually as in:
<=3Bpre>=3B
 =3B =3B =3B =3B = =3B =3B =3B PGSimpleDataSource dataSource =3D new PGSimpleDataSourc= e()=3B
 =3B =3B =3B =3B =3B =3B =3B dataSour= ce.setDatabaseName(postgresqlDatabaseName)=3B
 =3B =3B =3B&n= bsp=3B =3B =3B =3B dataSource.setServerName(postgresqlHost)=3B<= br> =3B =3B =3B =3B =3B =3B =3B dataSource.setU= ser(postgresqlUser)=3B
 =3B =3B =3B =3B =3B =3B&= nbsp=3B dataSource.setPassword(postgresqlPW)=3B
 =3B =3B =3B=  =3B =3B =3B =3B return dataSource=3B
<=3B/pre>=3B
If I want to get the datasource from jndi / tomcat as in:

<= =3BResource name=3D"jdbc/Zinc"
 =3B =3B =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B auth=3D"Container"
 = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B type=3D"javax.sql.DataSource"
 =3B =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B username=3D"yyyyyy"=
 =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B password=3D"xxxxxx"
 =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B driverClassName=3D= "org.postgresql.Driver"
 =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B url=3D"jdbc:postgresql:Zinc"
&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B maxActive=3D"20"
 =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B maxIdle=3D"4"/>=3B

t= he result set returned by metaData.getColumns(null=2C null=2C tableName=2C = null) is always empty.

However if I use MySQL=2C SQL Server or HSQLD= B the code also works in tomcat eg.

<=3BResource name=3D"jdbc/Zinc= "
 =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B auth=3D"Container"
 =3B =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B type=3D"javax.sql.D= ataSource"
 =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B username=3D"sa"
 =3B =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B password=3D""<= br> =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B driverClassName=3D"org.hsqldb.jdbcDriver"
 =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B= url=3D"jdbc:hsqldb:hsql://localhost/ZincDB"
 =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B maxActive=3D"= 20"
 =3B =3B =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B maxIdle=3D"4"/>=3B

works perfectly fine and m= etaData.getColumns returns exactly what I would expect.

My table nam= e only contains letters and is all lower case (postgresql jdbc is IMHO a bi= t quirky since table and field names seem to be partially case-sensitive).<= br>
Any ideas? Bug? the problem does seem to be a postgresql issue (and = not tomcat) =3B because code works fine for other JDBC Drivers.

= Thanks for your help.
= --_97be8a6b-13fc-4894-96f8-16b430f9ea32_--