Strange behaviour of JDBC driver for PostgreSQL

From: Carlos Correia <carlos(at)m16e(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Strange behaviour of JDBC driver for PostgreSQL
Date: 2002-12-17 17:54:07
Message-ID: 3DFF64BF.8080603@m16e.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc


I have problems with PostgreSQL when connecting from another machine in
the same network, after upgrading to 7.2.2 (Mandrake 9.0).

When invoking 'getColumns()' on a DatabaseMetaData object I get (very)
different results when I invoke it in the local machine (in which works
good) then when I invoke it in another machine in the network as you can
see below:

I've made a small Java class to reproduce its bizarre behaviour (I'm
using the same driver in both machines -
/usr/share/pgsql/jdbc7.2dev-1.2.jar from Mandrake 9.0), here is its output:

==================================
LOCAL MACHINE:
Database: PostgreSQL
Version : 7.2.2

schemas:

catalogs:
template1
template0
sedb

Fields for table: 'test'
ID TYPE TYPNAME NAME LEN NULLABLE
1 4 int4 4 NO
2 1 bpchar 20 YES

===================================
REMOTE MACHINE IN THE SAME NETWORK:
Database: PostgreSQL
Version : 6.5.2

schemas:

catalogs:

Fields for table: 'test'
ID TYPE TYPNAME NAME LEN NULLABLE
ERROR: No such attribute or function 'oid'

java.sql.SQLException: ERROR: No such attribute or function 'oid'

org.postgresql.Connection.ExecSQL(Connection.java at :393)
org.postgresql.jdbc2.DatabaseMetaData.getColumns( at DatabaseMetaData.jav
a:1880)
at DbTester.(DbTester.java:41)
at DbTester.main(DbTester.java:115)

================================
LAST LINES OF '/var/lib/pgsql/data/pg_hba.conf':
local all ident sameuser
host all 192.168.1.2 255.255.255.0 trust

191.168.1.2 is the client machine, running the same version of JDK (1.4.0).

Here is the test program that illustrates this behaviour:

import java.util.*;
import java.text.*;
import java.io.*;

import java.sql.*;

///////////////////////////////////////////////// ///////////
public class DbTester
{
Connection connection = null;
DatabaseMetaData dbmd = null;

//////////////////////////////////////////////// ////////////
public DbTester()
throws SQLException, ClassNotFoundException,
FileNotFoundException, IOException
{
Class.forName( "org.postgresql.Driver" );
Connection connection =
DriverManager.getConnection(
"jdbc:postgresql://devo/sedb", "carlos", "" );
dbmd = connection.getMetaData();
String databaseProductName = dbmd.getDatabaseProductName();
String databaseProductVersion = dbmd.getDatabaseProductVersion();

System.out.println(
"Database: " databaseProductName
"nVersion : " databaseProductVersion );

printSchemas();
printCatalogs();
System.out.println(
"nFields for table: 'test'"
"nIDtTYPEtTYPNAMEtNAMEtLENtNULLABLE" );
ResultSet rs = dbmd.getColumns( "%", "%", "test", "%" );
while( rs.next() )
printField( rs );
rs.close();
}

//////////////////////////////////////////////// ////////////
public void printField( ResultSet rs )
throws SQLException
{
System.out.println(
rs.getInt( 17 ) "t" rs.getInt( 5 ) "t"
rs.getString( 6 ) "t" rs.getInt( 7 ) "t"
rs.getString( 18 ) );
}

//////////////////////////////////////////////// ////////////
public void printSchemas()
throws SQLException
{
System.out.println( "nn schemas:" );
ResultSet rs = dbmd.getSchemas();
while ( rs.next() )
System.out.println( rs.getString( 1 ) );
rs.close();
}

//////////////////////////////////////////////// ////////////
public void printCatalogs()
throws SQLException
{
System.out.println( "nn catalogs:" );
ResultSet rs = dbmd.getCatalogs();
while ( rs.next() )
System.out.println( rs.getString( 1 ) );
rs.close();
}

//////////////////////////////////////////////// ////////////
public static void main( String[] args )
{
try
{
new DbTester();
}
catch( Exception e )
{
System.out.println( e.getMessage() );
e.printStackTrace();
}
}

}

best Regards,

Carlos Correia

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-12-17 18:04:57 Re: [PATCH] NPE in meta data getPrimaryKeys()
Previous Message Daniel Serodio 2002-12-17 17:44:17 Re: [PATCH] NPE in meta data getPrimaryKeys()