From: Thomas Strunz <beginner_@hotmail.de>
To: pgsql-jdbc@postgresql.org
Subject: metadata.getColumns() using Apache Tomcat / jndi
Date: Fri, 30 Sep 2011 08:13:47 +0200
Message-ID: <DUB114-W45402DA072DA2469848E6FEEF70@phx.gbl> (raw)
Hi all,
issue affects 9.1-901.jdbc4 and 9.0-801.jdbc4 driver.
i have following java code:
<pre>
Connection conn = dataSource.getConnection();
DatabaseMetaData metaData = conn.getMetaData();
this.databaseProductName = metaData.getDatabaseProductName();
ResultSet rsColumns = metaData.getColumns(
null, null, tableName, null);
while (rsColumns.next()) {
//..do work
}
rsColumns.close();
conn.close();
</pre>
This works fine when initializing the PostgreSQL DataSoource manually as in:
<pre>
PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setDatabaseName(postgresqlDatabaseName);
dataSource.setServerName(postgresqlHost);
dataSource.setUser(postgresqlUser);
dataSource.setPassword(postgresqlPW);
return dataSource;
</pre>
If I want to get the datasource from jndi / tomcat as in:
<Resource name="jdbc/Zinc"
auth="Container"
type="javax.sql.DataSource"
username="yyyyyy"
password="xxxxxx"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql:Zinc"
maxActive="20"
maxIdle="4"/>
the result set returned by metaData.getColumns(null, null, tableName, null) is always empty.
However if I use MySQL, SQL Server or HSQLDB the code also works in tomcat eg.
<Resource name="jdbc/Zinc"
auth="Container"
type="javax.sql.DataSource"
username="sa"
password=""
driverClassName="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost/ZincDB"
maxActive="20"
maxIdle="4"/>
works perfectly fine and metaData.getColumns returns exactly what I would expect.
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 tomcat) because code works fine for other JDBC Drivers.
Thanks for your help.
=
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: beginner_@hotmail.de
Subject: Re: metadata.getColumns() using Apache Tomcat / jndi
In-Reply-To: <DUB114-W45402DA072DA2469848E6FEEF70@phx.gbl>
References: <DUB114-W45402DA072DA2469848E6FEEF70@phx.gbl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox