Re: [PATCHES] Anoter JDBC Error

Поиск
Список
Период
Сортировка
От Aaron Mulder
Тема Re: [PATCHES] Anoter JDBC Error
Дата
Msg-id Pine.LNX.4.44.0210191924190.29694-100000@www.princetongames.org
обсуждение исходный текст
Ответ на Re: [PATCHES] Anoter JDBC Error  (Aaron Mulder <ammulder@alumni.princeton.edu>)
Ответы Re: [PATCHES] Anoter JDBC Error  (Dave Cramer <Dave@micro-automation.net>)
Re: [PATCHES] Anoter JDBC Error  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc
    Ahh, never mind.  I tried again a few minutes later, and got the
new behavior, which is to say a SQLException.  But I don't
understand why this is happening.  Here's what I'm doing:

    I create the database "test" (in my PG 7.2.2 DB) with a table with
3 columns, all integers.  I connect using the JDBC3 driver, get a
connection, get the databasemetadata, call

    dbmd.getColumns("test",null,"tablename","%");

    I get back a ResultSet.  Column 9 is an integer column,
DECIMAL_DIGITS.  If I call getObject, it tries to get an Integer object,
so even the ResultSet thinks it's an integer column.  However, the result
of getString/getFixedString used for new Integer(getFixedString()) is
apparently an empty String, causing the SQLException due to a badly
formatted Integer value.

    So now I'm confused.  What's an empty String doing in an integer
column when (if you believe the logic in getFixedString) the value was not
null?  Is this broken null handling?  Test program and results attached...

Aaron

import java.sql.*;

public class PostgresTest{
    public static void main(String args[]) {
        try {
            Class.forName("org.postgresql.Driver");
            Connection con =
DriverManager.getConnection("jdbc:postgresql://localhost/test", "test",
"password");
            DatabaseMetaData dmd = con.getMetaData();
            ResultSet rs = dmd.getColumns("test", null, "tablename", "%");
            rs.next();
            System.out.println("Col 9: "+rs.getInt(9)); // getObject(9)
            rs.close();
            con.close();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}


Bad Integer
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.toInt(AbstractJdbc1ResultSet.java:708)
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getInt(AbstractJdbc1ResultSet.java:148)
    at PostgresTest.main(PostgresTest.java:12)


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Aaron Mulder
Дата:
Сообщение: Re: [PATCHES] Anoter JDBC Error
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] /contrib/retep to gborg