Thread: Strange behaviour of JDBC driver for PostgreSQL
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
Carlos, Sorry, I didn't read your email carefully enough. The driver won't work with a 6.5.2 database, my apologies. You will need to upgrade the remote server Dave On Tue, 2002-12-17 at 12:54, Carlos Correia wrote: > 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 > > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Dave Cramer <Dave@micro-automation.net>
Carlos Correia <carlos@m16e.com> writes: > REMOTE MACHINE IN THE SAME NETWORK: > Database: PostgreSQL > Version : 6.5.2 Try updating. I don't think JDBC claims to support such an ancient server version as that. Considering the many known bugs and performance problems in 6.5.*, it's hardly worth your time to look for a compatibility workaround ... regards, tom lane
Dave Cramer wrote: >Carlos, > >Sorry, I didn't read your email carefully enough. The driver won't work >with a 6.5.2 database, my apologies. You will need to upgrade the remote >server > >Dave > >On Tue, 2002-12-17 at 12:54, Carlos Correia wrote: > > >>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 >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 3: if posting/reading through Usenet, please send an appropriate >>subscribe-nomail command to majordomo@postgresql.org so that your >>message can get through to the mailing list cleanly >> >> The information that is correct is the one from the localhost (version 7.2.2) I've never used such a version (6.x.x). I've downloaded the 7.3 driver (pg73jdbc3.jar) and... It happened the same (even with the same line numbers in the SQLException's stack trace). I'm sure I made no mistake! Note: I'm also sure there are no more Postgres installations in the network. Carlos Correia
Try issuing a "SELECT VERSION()" on the DB that DatabaseMetaData.getDatabaseProductVersion reports as being 6.5.2, and see what gives. On Tue, 2002-12-17 at 17:50, Carlos Correia wrote: > Dave Cramer wrote: > > >Carlos, > > > >Sorry, I didn't read your email carefully enough. The driver won't work > >with a 6.5.2 database, my apologies. You will need to upgrade the remote > >server > > > >Dave > > > >On Tue, 2002-12-17 at 12:54, Carlos Correia wrote: > > > > > >>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: > >> > >> <snip> > >> > >> > The information that is correct is the one from the localhost (version > 7.2.2) > I've never used such a version (6.x.x). > > I've downloaded the 7.3 driver (pg73jdbc3.jar) and... It happened the > same (even with the same line numbers in the SQLException's stack > trace). I'm sure I made no mistake! > Note: I'm also sure there are no more Postgres installations in the > network. > > Carlos Correia -- []'s Daniel Serodio
The information that is correct is the one from the localhost (version 7.2.2) I've never used such a version (6.x.x). I've downloaded the 7.3 driver (pg73jdbc3.jar) and... It happened the same (even with the same line numbers in the SQLException's stack trace). I'm sure I made no mistake! Note: I'm also sure there are no more Postgres installations in the network. Carlos Correia > Dave Cramer wrote: > >> Carlos, >> >> Sorry, I didn't read your email carefully enough. The driver won't work >> with a 6.5.2 database, my apologies. You will need to upgrade the remote >> server >> >> Dave >> >> On Tue, 2002-12-17 at 12:54, Carlos Correia wrote: >> >> >>> 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 >>> >>> >>> >>> ---------------------------(end of broadcast)--------------------------- >>> TIP 3: if posting/reading through Usenet, please send an appropriate >>> subscribe-nomail command to majordomo@postgresql.org so that your >>> message can get through to the mailing list cleanly >>> >> > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >
Carlos Correia wrote: > The information that is correct is the one from the localhost (version > 7.2.2) > I've never used such a version (6.x.x). > This lead us to believe you are using a server which is version 6.x.x... >>>> REMOTE MACHINE IN THE SAME NETWORK: >>>> Database: PostgreSQL >>>> Version: 6.5.2 Regards, Fernando > I've downloaded the 7.3 driver (pg73jdbc3.jar) and... It happened the > same (even with the same line numbers in the SQLException's stack > trace). I'm sure I made no mistake! > Note: I'm also sure there are no more Postgres installations in the > network. > > Carlos Correia > >> Dave Cramer wrote: >> >>> Carlos, >>> >>> Sorry, I didn't read your email carefully enough. The driver won't work >>> with a 6.5.2 database, my apologies. You will need to upgrade the remote >>> server >>> >>> Dave >>> >>> On Tue, 2002-12-17 at 12:54, Carlos Correia wrote: >>> >>> >>>> 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 >>>> >>>> >>>> >>>> ---------------------------(end of >>>> broadcast)--------------------------- >>>> TIP 3: if posting/reading through Usenet, please send an appropriate >>>> subscribe-nomail command to majordomo@postgresql.org so that your >>>> message can get through to the mailing list cleanly >>>> >>> >>> >> >> >> >> >> ---------------------------(end of broadcast)--------------------------- >> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >> > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > -- Fernando Nasser Red Hat Canada Ltd. E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9
Dave Cramer wrote: >Carlos, > >Is this a new message today, or one from yesterday? > > Dave, It is the same messge, but as I think that everyone is misunderstooding the problem, I'll try to resume it: 1. I don't know why the driver reports version 6.5.2, as I don't have such a version. 2. The only installation I have is of version 7.2.2 (at least that's what the output of 'select version()' says). 3. The problem: when I run the program on another machine of the same network, it has this strange behaviour (reporting version 6.5.2 and crashing when I invoke 'getColumns()' on DatabaseMetaData object). Carlos Correia >>>>>================================== >>>>>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 >>>>> >>>>> >>>>> >>>>>
Carlos Correia wrote: > > Dave Cramer wrote: > >> Carlos, >> >> Is this a new message today, or one from yesterday? >> >> > Dave, > > It is the same messge, but as I think that everyone is misunderstooding > the problem, I'll try to resume it: > > 1. I don't know why the driver reports version 6.5.2, as I don't have > such a version. The JDBC driver receives the version from the database backend when connecting and that is what is printed by the getDatabaseProductVersion() function. There is no way it can generate a 6.x.x version number by itself. You _must_ be connecting to a 6.5.2 backend. -- Fernando Nasser Red Hat Canada Ltd. E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9
Fernando, i am sure the db is version 7.2.2 Thanks anyway, Carlos Fernando Nasser wrote: > Carlos Correia wrote: > >> >> Dave Cramer wrote: >> >>> Carlos, >>> >>> Is this a new message today, or one from yesterday? >>> >>> >> Dave, >> >> It is the same messge, but as I think that everyone is >> misunderstooding the problem, I'll try to resume it: >> >> 1. I don't know why the driver reports version 6.5.2, as I don't have >> such a version. > > > The JDBC driver receives the version from the database backend when > connecting and that is what is printed by the > getDatabaseProductVersion() function. There is no way it can generate > a 6.x.x version number by itself. > > You _must_ be connecting to a 6.5.2 backend. > >
Carlos, To satisfy everyones curiosity why don't you try sending us the output of the following command from your local machine... $ psql -h REMOTEHOSTNAME -U USERNAME -c 'SELECT version();' DBNAME This will access the remote database DBNAME in much the same way as the driver does. Tom. On Thu, 2002-12-19 at 02:55, Carlos Correia wrote: > Fernando, > > i am sure the db is version 7.2.2 > > Thanks anyway, > > Carlos > > Fernando Nasser wrote: > > > Carlos Correia wrote: > > > >> > >> Dave Cramer wrote: > >> > >>> Carlos, > >>> > >>> Is this a new message today, or one from yesterday? > >>> > >>> > >> Dave, > >> > >> It is the same messge, but as I think that everyone is > >> misunderstooding the problem, I'll try to resume it: > >> > >> 1. I don't know why the driver reports version 6.5.2, as I don't have > >> such a version. > > > > > > The JDBC driver receives the version from the database backend when > > connecting and that is what is printed by the > > getDatabaseProductVersion() function. There is no way it can generate > > a 6.x.x version number by itself. > > > > You _must_ be connecting to a 6.5.2 backend. > > > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) -- Thomas O'Dowd, CEO, Nooper.com - Mobile Services Inc., Tokyo, Japan i-mode & FOMA consulting, development, testing: http://nooper.co.jp/
I've been working with Linux and Java for more then 4 years, so I'm sure of what I'm saying: never had or used such a version! Anyway, here's the output from: $ psql -h REMOTEHOSTNAME -U USERNAME -c 'SELECT version();' DBNAME version ---------------------------------------------------------------------------------------------------- PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 (Mandrake Linux 9.0 3.2-1mdk) (1 row) Best Regards, Carlos Thomas O'Dowd wrote: >Carlos, > >To satisfy everyones curiosity why don't you try sending us the output >of the following command from your local machine... > >$ psql -h REMOTEHOSTNAME -U USERNAME -c 'SELECT version();' DBNAME > >This will access the remote database DBNAME in much the same way as the >driver does. > >Tom. > >On Thu, 2002-12-19 at 02:55, Carlos Correia wrote: > > >>Fernando, >> >>i am sure the db is version 7.2.2 >> >>Thanks anyway, >> >>Carlos >> >>Fernando Nasser wrote: >> >> >> >>>Carlos Correia wrote: >>> >>> >>> >>>>Dave Cramer wrote: >>>> >>>> >>>> >>>>>Carlos, >>>>> >>>>>Is this a new message today, or one from yesterday? >>>>> >>>>> >>>>> >>>>> >>>>Dave, >>>> >>>>It is the same messge, but as I think that everyone is >>>>misunderstooding the problem, I'll try to resume it: >>>> >>>>1. I don't know why the driver reports version 6.5.2, as I don't have >>>>such a version. >>>> >>>> >>>The JDBC driver receives the version from the database backend when >>>connecting and that is what is printed by the >>>getDatabaseProductVersion() function. There is no way it can generate >>>a 6.x.x version number by itself. >>> >>>You _must_ be connecting to a 6.5.2 backend. >>> >>> >>> >>> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 2: you can get off all lists at once with the unregister command >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >> >>
Carlos, Ok, so the question becomes what database did the driver connect to? I can assure you it has no version information inside it so it must have received that from somewhere? Also the fact the the driver behaves differently when connected remotely suggests something is wrong. so what did you input for the -h parameter below? also can you write a java program that first gets the connection, and then waits for input, then in another terminal session do a netstat -nlp | grep 5432 Dave On Thu, 2002-12-19 at 06:20, Carlos Correia wrote: > I've been working with Linux and Java for more then 4 years, so I'm sure > of what I'm saying: never had or used such a version! > > Anyway, here's the output from: > > $ psql -h REMOTEHOSTNAME -U USERNAME -c 'SELECT version();' DBNAME > > > > version > ---------------------------------------------------------------------------------------------------- > PostgreSQL 7.2.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.2 > (Mandrake Linux 9.0 3.2-1mdk) > (1 row) > > Best Regards, > > Carlos > > Thomas O'Dowd wrote: > > >Carlos, > > > >To satisfy everyones curiosity why don't you try sending us the output > >of the following command from your local machine... > > > >$ psql -h REMOTEHOSTNAME -U USERNAME -c 'SELECT version();' DBNAME > > > >This will access the remote database DBNAME in much the same way as the > >driver does. > > > >Tom. > > > >On Thu, 2002-12-19 at 02:55, Carlos Correia wrote: > > > > > >>Fernando, > >> > >>i am sure the db is version 7.2.2 > >> > >>Thanks anyway, > >> > >>Carlos > >> > >>Fernando Nasser wrote: > >> > >> > >> > >>>Carlos Correia wrote: > >>> > >>> > >>> > >>>>Dave Cramer wrote: > >>>> > >>>> > >>>> > >>>>>Carlos, > >>>>> > >>>>>Is this a new message today, or one from yesterday? > >>>>> > >>>>> > >>>>> > >>>>> > >>>>Dave, > >>>> > >>>>It is the same messge, but as I think that everyone is > >>>>misunderstooding the problem, I'll try to resume it: > >>>> > >>>>1. I don't know why the driver reports version 6.5.2, as I don't have > >>>>such a version. > >>>> > >>>> > >>>The JDBC driver receives the version from the database backend when > >>>connecting and that is what is printed by the > >>>getDatabaseProductVersion() function. There is no way it can generate > >>>a 6.x.x version number by itself. > >>> > >>>You _must_ be connecting to a 6.5.2 backend. > >>> > >>> > >>> > >>> > >> > >>---------------------------(end of broadcast)--------------------------- > >>TIP 2: you can get off all lists at once with the unregister command > >> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > >> > >> > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org -- Dave Cramer <Dave@micro-automation.net>
Hi, Dave >Ok, so the question becomes what database did the driver connect to? > I'm pretty sure it's the only postgres database available. The network has only 2 machines: DEVO (the server -- a Mandrake 9.0 fresh installation -- add: 192.168.1.1) and RA (a Windows 2000 box -- add: 192.168.1.2), they are connected directly. Previously I was using Mandrake 8.0 (which came with version 7.0) and everything was working OK! Now, I made a fresh installation (formating ALL partitions) and Have only 2 DBs installed: postgres (7.2!) and MySQL. The tests were performed without being connected to the internet. >I >can assure you it has no version information inside it so it must have >received that from somewhere? Also the fact the the driver behaves >differently when connected remotely suggests something is wrong. >so what did you input for the -h parameter below? > The server name: DEVO > >also can you write a java program that first gets the connection, and >then waits for input, then in another terminal session do a netstat -nlp >| grep 5432 > > OK! I'll try BTW!, you have any idea about the meaning of SQLException reported? Thanks, Carlos
Carlos, The exception is indicating that you aren't connected to a database compatible with the driver. The driver doesn't support 6.5.2 databases so that's why all the confusion. Dave On Thu, 2002-12-19 at 07:41, Carlos Correia wrote: > Hi, Dave > > >Ok, so the question becomes what database did the driver connect to? > > > I'm pretty sure it's the only postgres database available. > The network has only 2 machines: DEVO (the server -- a Mandrake 9.0 > fresh installation -- add: 192.168.1.1) and RA (a Windows 2000 box -- > add: 192.168.1.2), they are connected directly. > Previously I was using Mandrake 8.0 (which came with version 7.0) and > everything was working OK! > Now, I made a fresh installation (formating ALL partitions) and Have > only 2 DBs installed: postgres (7.2!) and MySQL. > The tests were performed without being connected to the internet. > > >I > >can assure you it has no version information inside it so it must have > >received that from somewhere? Also the fact the the driver behaves > >differently when connected remotely suggests something is wrong. > >so what did you input for the -h parameter below? > > > The server name: DEVO > > > > >also can you write a java program that first gets the connection, and > >then waits for input, then in another terminal session do a netstat -nlp > >| grep 5432 > > > > > OK! I'll try > > BTW!, you have any idea about the meaning of SQLException reported? > > Thanks, > > Carlos -- Dave Cramer <Dave@micro-automation.net>