Re: TEXT columns should indentify as java.sql.Types.CLOB

From: Toni Helenius <Toni(dot)Helenius(at)syncrontech(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: TEXT columns should indentify as java.sql.Types.CLOB
Date: 2010-08-18 08:15:11
Message-ID: E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)opencloud(dot)com]
Sent: 18. elokuuta 2010 10:32
To: Toni Helenius
Cc: pgsql-jdbc(at)postgresql(dot)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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2010-08-18 08:19:14 Re: TEXT columns should indentify as java.sql.Types.CLOB
Previous Message Oliver Jowett 2010-08-18 07:31:31 Re: TEXT columns should indentify as java.sql.Types.CLOB