I need information about table and column name from the name of the constraint.
exists someone similar to connection.getMetadata().getX to retrieve the constraint information?
my test case is in Oracle Database, but my best solution I just want to solve with jdbc
If you are talking about foreign key and primary key constraints. The
DatabaseMetaDatadoes provide methods for retrieving this information: you can usegetImportedKeys(..)andgetCrossReference(..)for foreign keys, andgetPrimaryKeys(..)andgetExportedKeys(..)for primary keys.Just be careful how you use them:
getCrossReference(..)andgetExportedKeysare a bit counter-intuitive in my opinion.If you also need unique constraints, then you should be able to use
getIndexInfo(..)with passingtruefor the parameterunique.