J
J
Jsman2019-06-25 12:53:49
PostgreSQL
Jsman, 2019-06-25 12:53:49

Error calling getImportedKeys method?

Guys, hello everyone!
You need to get a foreign key.

Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection(configDataBase.getUrl(), configDataBase.getName(), configDataBase.getPassword());
Statement statement = connection.createStatement();

ResultSet rsSql = statement.executeQuery("select * from table_name limit 5");
while (rsSql.next()) {
    System.out.println("Номер в базе " + rsSql.getInt("id"));
}

DatabaseMetaData dm = connection.getMetaData();
ResultSet rsMeta = dm.getImportedKeys( "" , "" , "table_name" );

I do select first to check that everything is set up, I get the result, everything is ok. But in the line rsMeta an exception occurs
org.postgresql.util.PSQLException: ERROR: column t1.tgconstrname does not exist

If you have encountered this error, please tell me how to fix it!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-06-25
@SeniorDmitry

Check the versions of the software you are using. Your library providing the getImportedKeys call obviously doesn't know the version of PostgreSQL you're using.
The last release of postgresql where there was a tgconstrname field of the system catalog is far 8.4

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question