From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Why are clobs always "0"
Date: Sun, 1 Dec 2019 22:13:01 +0100
Message-ID: <4e8fc973-e6cb-5610-1e50-46bbb11e8813@gmx.net> (raw)
In-Reply-To: <1575221495.4549.0@mac.com>
References: <1575221495.4549.0@mac.com>
Arnie Morein schrieb am 01.12.2019 um 18:31:
> I have tested the most recent driver in three different SQL IDEs, and
> now with an application I'm writing that uses JDBC metadata, the
> comment on a field definition also isn't available as a string
> value.
>
> The only thing I ever see regarding data type "text" field values are
> either a 0 or a 1; neither of which applies.
>
> So why is this happening, even from the JDBC metadata results as
> well?
The Postgres JDBC driver does not have any problems with the "text"
data type, neither with reporting it properly through DatabaseMetaData
(it's reported as Types.VARCHAR) nor with retrieving values from
such a column.
The column size for such a column is reported as 2147483647
Column comments are reliably returned in the column "REMARKS" in the
result of DatabaseMetaData.getColumns()
Given the following table:
create table test (data text);
comment on column test.data is 'The text column';
then the following Java code:
ResultSet rs = connection.getDatabaseMetaData().getColumn(null, "public", "test", "%");
rs.next();
System.out.println("column_name: " + rs.getString("COLUMN_NAME"));
System.out.println("column_size: " + rs.getInt("COLUMN_SIZE"));
System.out.println("data_type: " + rs.getInt("DATA_TYPE"));
System.out.println("remarks: " + rs.getString("REMARKS"));
will output:
column_name: data
column_size: 2147483647
data_type: 12
remarks: The text column
With 12 being the value of java.sql.Types.VARCHAR
Thomas
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-general@postgresql.org
Cc: spam_eater@gmx.net
Subject: Re: Why are clobs always "0"
In-Reply-To: <4e8fc973-e6cb-5610-1e50-46bbb11e8813@gmx.net>
References: <1575221495.4549.0@mac.com> <4e8fc973-e6cb-5610-1e50-46bbb11e8813@gmx.net>
* 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