From: | dmp <danap(at)ttc-cmc(dot)net> |
---|---|
To: | Mansour Al Akeel <mansour(dot)alakeel(at)gmail(dot)com>, PostgreSQL JDBC <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Reading schema information |
Date: | 2015-05-25 13:48:51 |
Message-ID: | 55632843.8060109@ttc-cmc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-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,%20java.lang.String,%20java.lang.String,%20java.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/myjsqlview/datasource/DatabaseProperties.java
http://code.google.com/p/myjsqlview/source/browse/trunk/myjsqlview/src/com/dandymadeproductions/myjsqlview/gui/panels/TableTabPanel_PostgreSQL.java
************************
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");
From | Date | Subject | |
---|---|---|---|
Next Message | Mansour Al Akeel | 2015-05-25 14:49:53 | Re: Reading schema information |
Previous Message | Mansour Al Akeel | 2015-05-25 09:53:38 | Reading schema information |