What Are the Column Privileges? JDBC

A database column’s privileges refers to finding a description of the access rights for columns of a table available in a catalog or schema. DatabaseMetaData provides a method, getColumnPrivileges(), to do just that. This method returns the result as a ResultSet object where each row is a column privilege description. In web-based applications, returning the result as a ResultSet is not useful. It is better to return the result as an HTML/XML object so that the client can extract the required information and display it in a desired format. It would be wrong to assume that this privilege applies to all columns; while this may be true for some systems, it is not true for all.

getColumnPrivileges() returns only privileges that match the schema and table name criteria. They are ordered by COLUMN_NAME and PRIVILEGE. Each privilege description has the columns shown in Table.

Table : Columns for Result of Invoking getColumnPrivileges()

Columns for Result of Invoking getColumnPrivileges()

The getColumnPrivileges() method has the following signature:

where

  • catalog is a catalog name; "" retrieves those without a catalog.
  • schema is a schema name; "" retrieves those without a schema.
  • table is a table name pattern.
  • columnNamePattern is a column name pattern.

Next let’s look at a Java servlet, GetTablePrivileges, which has the following signature:

The Solution

Invoking GetColumnPrivileges for MySQL

Figure: shows how to run the solution for the MySQL database.

Invoking GetColumnPrivileges for MySQL

Invoking GetColumnPrivileges for Oracle

Figure : shows how to run the solution for the Oracle database. As you can observe, Oracledriver does not implement the getColumnPrivileges() method.

Invoking GetColumnPrivileges for Oracle


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JDBC Topics