pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Toni Helenius <Toni.Helenius@syncrontech.com>
To: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
Subject: Re: TEXT columns should indentify as java.sql.Types.CLOB
Date: Wed, 18 Aug 2010 11:15:11 +0300
Message-ID: <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com> (raw)
In-Reply-To: <4C6B8C53.3040609@opencloud.com>
References: <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0DF3@ink.sad.syncrontech.com>
	<4C695AED.5040806@ttc-cmc.net>
	<E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EAE@ink.sad.syncrontech.com>
	<4C6B8C53.3040609@opencloud.com>

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



view thread (14+ messages)  latest in thread

Message-ID: <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com>
Permalink:  ../E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com/
Also on:    postgresql.org/message-id/E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: Toni.Helenius@syncrontech.com, oliver@opencloud.com
  Subject: Re: TEXT columns should indentify as java.sql.Types.CLOB
  In-Reply-To: <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com>
  References: <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0DF3@ink.sad.syncrontech.com> <4C695AED.5040806@ttc-cmc.net> <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EAE@ink.sad.syncrontech.com> <4C6B8C53.3040609@opencloud.com> <E6A9CAA76548CB4EB02D2E3B174DD3B155381F0EC3@ink.sad.syncrontech.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox