mercredi 17 février 2016

Java: JDBC get Column Constraints

Currently using JDBC I am able to retrieve column information from tables in my database. I am able to retrieve the name, column type and if the column allows null values.

However I'm trying to retrieve if the column has any constraints, specifically the Unique constraint.

Code:

rs = databaseMetaData.getColumns(null, null, tableName, null);
while (rs.next()) {
    String columnName = rs.getString(4);
    String TypeName = rs.getString(6);
    String nullable = rs.getString(18);

Aucun commentaire:

Enregistrer un commentaire