I hope that the program below will help.
----------------------------------
ShowDBMetaData.java
import java.sql.*;
import java.util.*;
/**
* Used to perform some tests with the <code>DatabaseMetaData</code>.
*/
public class ShowDBMetaData
{
private static final String DRIVER = "com.informix.jdbc.IfxDriver"; // TODO : change
// TODO : change
private static final String URL = "jdbc:informix-sqli:...";
// TODO : change
private static final String CATALOG = null;
// TODO : change
private static final String SCHEMA = "informix";
// TODO : change
private static final String TABLE = "tableName";
public void printDbInfos() throws Exception
{
Connection connection = null;
try
{
Class.forName( DRIVER );
connection = DriverManager.getConnection( URL );
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println( "Database Product Name : " +
dbmd.getDatabaseProductName() );
System.out.println( "Database Product Version : " +
dbmd.getDatabaseProductVersion() );
System.out.println( "Driver Name : " +
dbmd.getDriverName() );
System.out.println( "Driver Version : " +
dbmd.getDriverVersion() );
System.out.println();
System.out.println( "Max. length of a statement in byte : " +
dbmd.getMaxStatementLength() );
System.out.println( "Max. number of tables in SELECT : " +
dbmd.getMaxTablesInSelect() );
System.out.println( "Max. number of columns in SELECT : " +
dbmd.getMaxColumnsInSelect() );
System.out.println( "Max. number of columns in GROUP BY : " +
dbmd.getMaxColumnsInGroupBy() );
System.out.println( "Max. number of columns in ORDER BY : " +
dbmd.getMaxColumnsInOrderBy() );
System.out.println( "Identifier Quote String : |" +
dbmd.getIdentifierQuoteString() + "|");
System.out.println();
System.out.println("The URL : " + URL);
System.out.println("The CATALOG: " + CATALOG);
System.out.println("The SCHEMA : " + SCHEMA);
System.out.println("The TABLE : " + TABLE);
System.out.println();
System.out.println("\n\nThe catalogs" );
ResultSet catalogs = dbmd.getCatalogs();
ResultSetMetaData catalogsMetaData = catalogs.getMetaData();
System.out.println(" (" + catalogsMetaData.getColumnCount() + " columns" + ")\n");
while (catalogs.next())
{
int index = 1;
while (index <= catalogsMetaData.getColumnCount())
{
System.out.print(catalogs.getObject(index) + ", ");
index++;
}
System.out.println();
}
catalogs.close();
System.out.println("\n\nThe schemas" );
ResultSet schemas = dbmd.getSchemas();
ResultSetMetaData schemasMetaData = schemas.getMetaData();
System.out.println(" (" + schemasMetaData.getColumnCount() + " columns" + ")\n");
while (schemas.next())
{
int index = 1;
while (index <= schemasMetaData.getColumnCount())
{
System.out.print(schemas.getObject(index) + ", ");
index++;
}
System.out.println();
}
schemas.close();
System.out.println("\n\nThe primary keys" );
ResultSet primKeys = dbmd.getPrimaryKeys(CATALOG, SCHEMA, TABLE);
ResultSetMetaData primKeysMetaData = primKeys.getMetaData();
System.out.println(" (" + primKeysMetaData.getColumnCount() + " columns" + ")\n");
while (primKeys.next())
{
int index = 1;
while (index <= primKeysMetaData.getColumnCount())
{
System.out.print(primKeys.getObject(index) + ", ");
index++;
}
System.out.println();
}
primKeys.close();
System.out.println("\n\nThe tables" );
ResultSet tables = dbmd.getTables(CATALOG, SCHEMA, TABLE,
new String[]{"TABLE", "VIEW"});
ResultSetMetaData tablesMetaData = tables.getMetaData();
System.out.println(" (" + tablesMetaData.getColumnCount() + " columns" + ")\n");
while (tables.next())
{
int index = 1;
while (index <= tablesMetaData.getColumnCount())
{
System.out.print(tables.getObject(index) + ", ");
index++;
}
System.out.print("\nSCHEM: " + tables.getString("TABLE_SCHEM"));
System.out.println(", NAME : " + tables.getString("TABLE_NAME"));
System.out.println();
}
tables.close();
System.out.println("\n\nThe columns" );
ResultSet columns = dbmd.getColumns(CATALOG, SCHEMA, TABLE, null);
while (columns.next())
{
System.out.println( "tableCategory: " + columns.getString("TABLE_CAT") );
System.out.println( "tableSchema: " + columns.getString("TABLE_SCHEM") );
System.out.println( "sqlType: " + columns.getInt("DATA_TYPE") );
System.out.println( "sqlTypeName: " + columns.getString("TYPE_NAME") );
System.out.println( "columnName: " + columns.getString("COLUMN_NAME") );
System.out.println( "columnDef: " + columns.getString("COLUMN_DEF") );
System.out.println( "columnSize: " + columns.getInt("COLUMN_SIZE") );
System.out.println( "decimalDigits: " + columns.getInt("DECIMAL_DIGITS") );
System.out.println();
}
columns.close();
}
catch( SQLException e )
{
System.out.println("Error code: " + e.getErrorCode());
System.out.println("SQL state : " + e.getSQLState());
e.printStackTrace();
}
finally
{
try
{
connection.close();
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
public static void main( String[] anArgs )
{
ShowDBMetaData t = new ShowDBMetaData();
try
{
t.printDbInfos();
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
ShowDBMetaData.java
----------------------------------
Best Regards
Jean-Claude
David R Robison wrote:
> Here is the postgres description of the table that it is having trouble with:
>
> Table "public.row_status_type"
> Column | Type | Modifiers
> ------------------+------------------------+-----------
> rstat_type_cod | smallint | not null
> name | character varying(254) | not null
> gmt_last_updated | character varying(29) |
> last_upd_db_site | integer |
> last_upd_db_id | integer |
> rstat_type_code | smallint |
> Indexes: mim_con_012_pk primary key btree (rstat_type_cod)
>
> David Robison
>
> Quoting David R Robison <[email protected]>:
>
>
>>Hello, I new to Middlegen. I trying to run middlegen against a
>>postgresql
>>database. When I run it against one of my tables, I get the following
>>error:
>>
>>[middlegen] java.lang.IllegalArgumentException: There is no column
>>named
>>UNSPECIFIED in the table named row_status_type
>>[middlegen] at middlegen.DbTable.getColumn(DbTable.java:304)
>>[middlegen] at
>>middlegen.MiddlegenPopulator.addCrossref(MiddlegenPopulator.java:635)
>>[middlegen] at
>>middlegen.MiddlegenPopulator.addRelations(MiddlegenPopulator.java:375)
>>[middlegen] at
>>middlegen.MiddlegenPopulator.populate(MiddlegenPopulator.java:257)
>>[middlegen] at
>>middlegen.MiddlegenTask.execute(MiddlegenTask.java:403)
>>[middlegen] at
>>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:193)
>>[middlegen] at org.apache.tools.ant.Task.perform(Task.java:341)
>>[middlegen] at org.apache.tools.ant.Target.execute(Target.java:309)
>>[middlegen] at
>>org.apache.tools.ant.Target.performTasks(Target.java:336)
>>[middlegen] at
>>org.apache.tools.ant.Project.executeTarget(Project.java:1339)
>>[middlegen] at
>>org.apache.tools.ant.Project.executeTargets(Project.java:1255)
>>[middlegen] at org.apache.tools.ant.Main.runBuild(Main.java:609)
>>[middlegen] at org.apache.tools.ant.Main.start(Main.java:196)
>>[middlegen] at org.apache.tools.ant.Main.main(Main.java:235)
>>
>>Any ideas what the problem might be?
>>Thanks,
>>David Robison
>>
>>
>>-------------------------------------------------------
>>This SF. Net email is sponsored by: GoToMyPC
>>GoToMyPC is the fast, easy and secure way to access your computer from
>>any Web browser or wireless device. Click here to Try it Free!
>>https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
>>_______________________________________________
>>middlegen-user mailing list
>>[email protected]
>>https://lists.sourceforge.net/lists/listinfo/middlegen-user
>>
>
>
>
> -------------------------------------------------------
> This SF. Net email is sponsored by: GoToMyPC
> GoToMyPC is the fast, easy and secure way to access your computer from
> any Web browser or wireless device. Click here to Try it Free!
> https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
> _______________________________________________
> middlegen-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/middlegen-user
>
-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.