Re: TEXT columns should indentify as java.sql.Types.CLOB - Mailing list pgsql-jdbc

From Toni Helenius
Subject Re: TEXT columns should indentify as java.sql.Types.CLOB
Date
Msg-id E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com
Whole thread Raw
In response to Re: TEXT columns should indentify as java.sql.Types.CLOB  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: TEXT columns should indentify as java.sql.Types.CLOB
List pgsql-jdbc
Hi,

Here is the best I can do, I'm sure you'll manage to fill in the holes:

private static final String DRIVER = "org.postgresql.Driver";
private static final String URL = "jdbc:postgresql://localhost/testdb";
private static final String USERNAME = "root";
private static final String PASSWORD = "";

Class.forName("DRIVER");
Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
DatabaseMetaData  metaFrom = connection.getMetaData();
// Get the columns
ResultSet cols = metaFrom.getColumns(null, YOUR_SCHEMA_HERE, YOUR_TABLE_NAME_HERE, null);

// Get column info
while (cols.next()) {
    println("Column name: " + cols.getString("COLUMN_NAME"));
    short type = cols.getShort("DATA_TYPE"));

    if (java.sql.Types.BOOLEAN == type) {
        println("A boolean");
    }
    else {
        println("Not a boolean! (" + type + ")");
    }
    println("Postgre calls this: " + cols.getString("TYPE_NAME"));
    }


-----Original Message-----
From: Oliver Jowett [mailto:oliver@opencloud.com]
Sent: 18. elokuuta 2010 10:32
To: Toni Helenius
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] TEXT columns should indentify as java.sql.Types.CLOB

Toni Helenius wrote:
> Hi,
>
> An definitely a bug: BOOLEAN columns get identified as java.sql.Types.VARCHAR. Not java.sql.Types.BOOLEAN as they
should.I end up getting SQL create statements where boolean fields are translated back as VARCHAR(1). 

That does sound like a bug. Do you have a self-contained testcase
showing the problem?

-O

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: TEXT columns should indentify as java.sql.Types.CLOB
Next
From: Oliver Jowett
Date:
Subject: Re: TEXT columns should indentify as java.sql.Types.CLOB