RE: ResultSetMetaData problems (getColumnType() and -TypeName)

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: 'Þórhallur Hálfdánarson' <tolli(at)margmidlun(dot)is>, "'pgsql-interfaces(at)postgresql(dot)org'" <pgsql-interfaces(at)postgresql(dot)org>
Subject: RE: ResultSetMetaData problems (getColumnType() and -TypeName)
Date: 2000-07-19 06:36:28
Message-ID: 1B3D5E532D18D311861A00600865478CF1B0EF@exchange1.nt.maidstone.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Can you run this with debugging enabled on the connection please?

ie: After connecting issue the line:
DriverManager.setLogStream(System.err);

Ignore the compiler warning.

The problem you have is that Field issues a small query to fetch the
Column's name from pg_type and this query is failing. The output of the log
may help see why this query is failing.

Thanks, Peter
--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council
-----Original Message-----
From: Þórhallur Hálfdánarson [mailto:tolli(at)margmidlun(dot)is]
Sent: Tuesday, July 18, 2000 5:21 PM
To: 'pgsql-interfaces(at)postgresql(dot)org'
Subject: [INTERFACES] ResultSetMetaData problems (getColumnType() and
-TypeName)

Hi
I've seen some postings on this subject since ages ago. The code and the
output pretty much says what there has to be said (there was as example
similar to this code somewhere). Sorry for the Icelandic, though. :-)
<code>
int iFjoldi = rsmd.getColumnCount();
System.out.println("Fjöldi dálka í töflunni sjálfri: "+ iFjoldi);
for (int i=1; i <= iFjoldi; i++)
{
System.out.println("Dálkur "+ i);
try
{
rsmd = rs.getMetaData();
System.out.println("Dálkur "+ i +": "+
rsmd.getColumnType(i));
System.out.println("Dálkur "+ i +": "+
rsmd.getColumnTypeName(i));
System.out.println("Ég er gimp");
}
catch (SQLException e)
{
System.out.println("Fönky SQL Exception: "+ e.toString());
}
catch (Exception e)
{
System.out.println("Fönky Exception: "+ e.toString());
e.printStackTrace();
}
}
</code>
<output>
Fjöldi dálka í töflunni sjálfri: 4
Dálkur 1
Fönky Exception: java.lang.NullPointerException:
java.lang.NullPointerException:
at org.postgresql.Connection.ExecSQL(Connection.java:312)
at org.postgresql.Field.getSQLType(Field.java:79)
at
org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSetMetaData.java:
363)
at com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)

at Gagnagaur.main(Gagnagaur.java:13)
Dálkur 2
Fönky Exception: java.lang.NullPointerException:
java.lang.NullPointerException:
at org.postgresql.Connection.ExecSQL(Connection.java:312)
at org.postgresql.Field.getSQLType(Field.java:79)
at
org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSetMetaData.java:
363)
at com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)

at Gagnagaur.main(Gagnagaur.java:13)
Dálkur 3
Fönky Exception: java.lang.NullPointerException:
java.lang.NullPointerException:
at org.postgresql.Connection.ExecSQL(Connection.java:312)
at org.postgresql.Field.getSQLType(Field.java:79)
at
org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSetMetaData.java:
363)
at com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)

at Gagnagaur.main(Gagnagaur.java:13)
Dálkur 4
Fönky Exception: java.lang.NullPointerException:
java.lang.NullPointerException:
at org.postgresql.Connection.ExecSQL(Connection.java:312)
at org.postgresql.Field.getSQLType(Field.java:79)
at
org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSetMetaData.java:
363)
at com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)

at Gagnagaur.main(Gagnagaur.java:13)
</output>

The same has shown up on setups:
Setup A)
Machine S)
RedHat Linux 6.0
PostgreSQL 6.5.1 (with JDBC, other stuff working fine)
Machine J)
RedHat Linux 6.1
Sun JDK:
java version "1.2.2"
Classic VM (build 1.2.2-L, green threads, nojit)
jdbc6.5-1.2.jar
Setup B)
Machine T)
RedHat Linux 6.2
PostgreSQL 7.0.2
$ rpm -qa |grep postgres
postgresql-jdbc-7.0.2-2
postgresql-odbc-7.0.2-2
postgresql-7.0.2-2
postgresql-server-7.0.2-2
postgresql-devel-7.0.2-2
Sun JDK

Now.... do you have any tips ?

Regards,
Tolli
tolli(at)margmidlun(dot)is

Browse pgsql-interfaces by date

  From Date Subject
Next Message Peter Mount 2000-07-19 06:41:50 RE: jdbc how to get SERIAL
Previous Message radifan karami 2000-07-19 04:04:53 RE: Clob or Blob in JDBC -> ImageViewer