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

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

From
Þórhallur Hálfdánarson
Date:
<p><font size="2">Me stupid. :-)</font><p><font size="2">There were no rows returned. I didn't even think about that, I
tookit for granted that this would be possible.</font><p><font size="2">Is there any change that this will not be
neededin future releases ?</font><br /><p><font size="2">Regards,</font><br /><font size="2">Tolli</font><br /><p><font
size="2">>-----Original Message-----</font><br /><font size="2">> From: Peter Mount [<a
href="mailto:petermount@it.maidstone.gov.uk">mailto:petermount@it.maidstone.gov.uk</a>]</font><br/><font size="2">>
Sent:19. júlí 2000 06:36</font><br /><font size="2">> To: 'Þórhallur Hálfdánarson';
'pgsql-interfaces@postgresql.org'</font><br/><font size="2">> Subject: RE: [INTERFACES] ResultSetMetaData problems
(getColumnType()</font><br/><font size="2">> and -TypeName)</font><br /><font size="2">> </font><br /><font
size="2">></font><br /><font size="2">> Can you run this with debugging enabled on the connection
please?</font><br/><font size="2">> </font><br /><font size="2">> ie: After connecting issue the line:</font><br
/><fontsize="2">>         DriverManager.setLogStream(System.err);</font><br /><font size="2">> </font><br /><font
size="2">>Ignore the compiler warning.</font><br /><font size="2">> </font><br /><font size="2">> The problem
youhave is that Field issues a small query to fetch the</font><br /><font size="2">> Column's name from pg_type and
thisquery is failing. The </font><br /><font size="2">> output of the log</font><br /><font size="2">> may help
seewhy this query is failing.</font><br /><font size="2">> </font><br /><font size="2">> Thanks, Peter</font><br
/><fontsize="2">> -- </font><br /><font size="2">> Peter Mount </font><br /><font size="2">> Enterprise
Support</font><br /><font size="2">> Maidstone Borough Council </font><br /><font size="2">> Any views stated are
myown, and not those of Maidstone </font><br /><font size="2">> Borough Council </font><br /><font size="2">>
-----OriginalMessage-----</font><br /><font size="2">> From: Þórhallur Hálfdánarson [<a
href="mailto:tolli@margmidlun.is">mailto:tolli@margmidlun.is</a>]</font><br/><font size="2">> Sent: Tuesday, July
18,2000 5:21 PM</font><br /><font size="2">> To: 'pgsql-interfaces@postgresql.org'</font><br /><font size="2">>
Subject:[INTERFACES] ResultSetMetaData problems (getColumnType() and</font><br /><font size="2">>
-TypeName)</font><br/><font size="2">> </font><br /><font size="2">> </font><br /><font size="2">> Hi
</font><br/><font size="2">> I've seen some postings on this subject since ages ago. The </font><br /><font
size="2">>code and the</font><br /><font size="2">> output pretty much says what there has to be said (there was
</font><br/><font size="2">> as example</font><br /><font size="2">> similar to this code somewhere). Sorry for
theIcelandic, though. :-)</font><br /><font size="2">> <code> </font><br /><font size="2">> int iFjoldi =
rsmd.getColumnCount();</font><br /><font size="2">> System.out.println("Fjöldi dálka í töflunni sjálfri: "+
iFjoldi);</font><br /><font size="2">> for (int i=1; i <= iFjoldi; i++) </font><br /><font size="2">> {
</font><br/><font size="2">>         System.out.println("Dálkur "+ i); </font><br /><font size="2">>         try
</font><br/><font size="2">>         { </font><br /><font size="2">>                 rsmd = rs.getMetaData();
</font><br/><font size="2">>                 System.out.println("Dálkur "+ i +": "+</font><br /><font size="2">>
rsmd.getColumnType(i));</font><br /><font size="2">>                 System.out.println("Dálkur "+ i +":
"+</font><br/><font size="2">> rsmd.getColumnTypeName(i)); </font><br /><font size="2">>                
System.out.println("Éger gimp"); </font><br /><font size="2">>         } </font><br /><font size="2">>        
catch(SQLException e) </font><br /><font size="2">>         { </font><br /><font size="2">>                
System.out.println("FönkySQL Exception: "+ </font><br /><font size="2">> e.toString()); </font><br /><font
size="2">>        } </font><br /><font size="2">>         catch (Exception e) </font><br /><font
size="2">>        { </font><br /><font size="2">>                 System.out.println("Fönky Exception: "+
</font><br/><font size="2">> e.toString()); </font><br /><font size="2">>                 e.printStackTrace();
</font><br/><font size="2">>         } </font><br /><font size="2">> } </font><br /><font size="2">>
</code></font><br /><font size="2">> <output> </font><br /><font size="2">> Fjöldi dálka í töflunni
sjálfri:4 </font><br /><font size="2">> Dálkur 1 </font><br /><font size="2">> Fönky Exception:
java.lang.NullPointerException:</font><br /><font size="2">> java.lang.NullPointerException: </font><br /><font
size="2">>        at org.postgresql.Connection.ExecSQL(Connection.java:312) </font><br /><font size="2">>        
atorg.postgresql.Field.getSQLType(Field.java:79) </font><br /><font size="2">>         at</font><br /><font
size="2">>org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSet</font><br /><font size="2">>
MetaData.java:</font><br/><font size="2">> 363) </font><br /><font size="2">>         at </font><br /><font
size="2">>com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)</font><br /><font size="2">>
</font><br/><font size="2">>         at Gagnagaur.main(Gagnagaur.java:13) </font><br /><font size="2">> Dálkur 2
</font><br/><font size="2">> Fönky Exception: java.lang.NullPointerException: </font><br /><font size="2">>
java.lang.NullPointerException:</font><br /><font size="2">>         at
org.postgresql.Connection.ExecSQL(Connection.java:312)</font><br /><font size="2">>         at
org.postgresql.Field.getSQLType(Field.java:79)</font><br /><font size="2">>         at</font><br /><font
size="2">>org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSet</font><br /><font size="2">>
MetaData.java:</font><br/><font size="2">> 363) </font><br /><font size="2">>         at </font><br /><font
size="2">>com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)</font><br /><font size="2">>
</font><br/><font size="2">>         at Gagnagaur.main(Gagnagaur.java:13) </font><br /><font size="2">> Dálkur 3
</font><br/><font size="2">> Fönky Exception: java.lang.NullPointerException: </font><br /><font size="2">>
java.lang.NullPointerException:</font><br /><font size="2">>         at
org.postgresql.Connection.ExecSQL(Connection.java:312)</font><br /><font size="2">>         at
org.postgresql.Field.getSQLType(Field.java:79)</font><br /><font size="2">>         at</font><br /><font
size="2">>org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSet</font><br /><font size="2">>
MetaData.java:</font><br/><font size="2">> 363) </font><br /><font size="2">>         at </font><br /><font
size="2">>com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)</font><br /><font size="2">>
</font><br/><font size="2">>         at Gagnagaur.main(Gagnagaur.java:13) </font><br /><font size="2">> Dálkur 4
</font><br/><font size="2">> Fönky Exception: java.lang.NullPointerException: </font><br /><font size="2">>
java.lang.NullPointerException:</font><br /><font size="2">>         at
org.postgresql.Connection.ExecSQL(Connection.java:312)</font><br /><font size="2">>         at
org.postgresql.Field.getSQLType(Field.java:79)</font><br /><font size="2">>         at</font><br /><font
size="2">>org.postgresql.jdbc2.ResultSetMetaData.getColumnType(ResultSet</font><br /><font size="2">>
MetaData.java:</font><br/><font size="2">> 363) </font><br /><font size="2">>         at </font><br /><font
size="2">>com.margmidlun.LIN.Upplysingakerfi.Importer.go(Importer.java:132)</font><br /><font size="2">>
</font><br/><font size="2">>         at Gagnagaur.main(Gagnagaur.java:13) </font><br /><font size="2">>
</output></font><br /><font size="2">> </font><br /><font size="2">> </font><br /><font size="2">> The
samehas shown up on setups: </font><br /><font size="2">> Setup A) </font><br /><font size="2">>   Machine S)
</font><br/><font size="2">>     RedHat Linux 6.0 </font><br /><font size="2">>     PostgreSQL 6.5.1 (with JDBC,
otherstuff working fine) </font><br /><font size="2">>   Machine J) </font><br /><font size="2">>     RedHat
Linux6.1 </font><br /><font size="2">>      Sun JDK: </font><br /><font size="2">>       java version "1.2.2"
</font><br/><font size="2">>       Classic VM (build 1.2.2-L, green threads, nojit) </font><br /><font
size="2">>    jdbc6.5-1.2.jar </font><br /><font size="2">> Setup B) </font><br /><font size="2">>   Machine
T)</font><br /><font size="2">>     RedHat Linux 6.2 </font><br /><font size="2">>     PostgreSQL 7.0.2
</font><br/><font size="2">>       $ rpm -qa |grep postgres </font><br /><font size="2">>      
postgresql-jdbc-7.0.2-2</font><br /><font size="2">>       postgresql-odbc-7.0.2-2 </font><br /><font
size="2">>      postgresql-7.0.2-2 </font><br /><font size="2">>       postgresql-server-7.0.2-2 </font><br
/><fontsize="2">>       postgresql-devel-7.0.2-2 </font><br /><font size="2">>     Sun JDK </font><br /><font
size="2">></font><br /><font size="2">> </font><br /><font size="2">> </font><br /><font size="2">> Now....
doyou have any tips ? </font><br /><font size="2">> </font><br /><font size="2">> </font><br /><font
size="2">>Regards, </font><br /><font size="2">> Tolli </font><br /><font size="2">> tolli@margmidlun.is
</font><br/><font size="2">> </font>