Thomas,
Any chance you can see what is in the server logs ?
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
On Fri, Sep 30, 2011 at 2:13 AM, Thomas Strunz <beginner_@hotmail.de> wrote:
> 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.
>