From: dmp <danap@ttc-cmc.net>
To: Mansour Al Akeel <mansour.alakeel@gmail.com>
To: PostgreSQL JDBC <pgsql-jdbc@postgresql.org>
Subject: Re: Reading schema information
Date: Mon, 25 May 2015 07:48:51 -0600
Message-ID: <55632843.8060109@ttc-cmc.net> (raw)
In-Reply-To: <CAFvvX=aeL4yfjA8Ng4Aek3W_FzO9zgihtRTXzaaaFw55d9GU1A@mail.gmail.com>
References: <CAFvvX=aeL4yfjA8Ng4Aek3W_FzO9zgihtRTXzaaaFw55d9GU1A@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Mansour Al Akeel wrote:
> Sorry for missing the email subject in my previous email !
>
> I am trying to get some information about a coloum using the method:
>
> DatabaseMetaData.getString("IS_GENERATEDCOLUMN")
>
> However it is throwing an exception:
>
> org.postgresql.util.PSQLException: The column name IS_GENERATEDCOLUMN
> was not found in this ResultSet.
>
> Based on javadoc for getColumns method:
>
> http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getColumns(java.lang.String,...)
>
>
> We have:
>
> IS_GENERATEDCOLUMN String => Indicates whether this is a generated column
>
> YES --- if this a generated column
> NO --- if this not a generated column
> empty string --- if it cannot be determined whether this is a generated column
>
>
> My questions is, is this a bug ? if not, how can I obtain this
> information about a column (if it's generated or not) ?
>
>
> Thank you.
>
Hello,
Try the following attached code, may have some syntax errors.
A complete example of collecting database and table meta
data my be obtained from my project on GoogleCode.
danap.
http://code.google.com/p/myjsqlview/http://code.google.com/p/myjsqlview/source/browse/trunk/myjsqlview/src/com/dandymadeproductions/myjs...http://code.google.com/p/myjsqlview/source/browse/trunk/myjsqlview/src/com/dandymadeproductions/myjs...
************************
Statement sqlStatement = dbConnection.createStatement();
String sqlStatementString = "SELECT * FROM " + "myTable" + " LIMIT 1";
ResultSet db_resultSet = sqlStatement.executeQuery(sqlStatementString);
DatabaseMetaData dbMetaData = dbConnection.getMetaData();
ResultSetMetaData tableMetaData = db_resultSet.getMetaData();
ResultSet rs1 = dbMetaData.getColumns("myDatabase",
tableMetaData.getCatalogName(1),
tableMetaData.getSchemaName(1),
tableMetaData.getTableName(1));
String isGenerated = rs1.getString("IS_GENERATEDCOLUMN");
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: danap@ttc-cmc.net, mansour.alakeel@gmail.com
Subject: Re: Reading schema information
In-Reply-To: <55632843.8060109@ttc-cmc.net>
References: <CAFvvX=aeL4yfjA8Ng4Aek3W_FzO9zgihtRTXzaaaFw55d9GU1A@mail.gmail.com> <55632843.8060109@ttc-cmc.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