title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | apilocation | apiname | apitype |
---|---|---|---|---|---|---|---|---|---|---|
getColumnPrivileges Method (SQLServerDatabaseMetaData) |
getColumnPrivileges Method (SQLServerDatabaseMetaData) |
David-Engel |
davidengel |
01/19/2017 |
sql |
connectivity |
reference |
sqljdbc.jar |
SQLServerDatabaseMetaData.getColumnPrivileges |
Assembly |
[!INCLUDEDriver_JDBC_Download]
Retrieves a description of the access rights for the columns in a table.
public java.sql.ResultSet getColumnPrivileges(java.lang.String catalog,
java.lang.String schema,
java.lang.String table,
java.lang.String col)
catalog
A String that contains the catalog name.
schema
A String that contains the schema name.
table
A String that contains the table name.
col
A String that contains the column name pattern.
A SQLServerResultSet object.
This getColumnPrivileges method is specified by the getColumnPrivileges method in the java.sql.DatabaseMetaData interface.
The result set returned by the getColumnPrivileges method will contain the following information:
Name | Type | Description |
---|---|---|
TABLE_CAT | String | The catalog name. |
TABLE_SCHEM | String | The table schema name. |
TABLE_NAME | String | The table name. |
COLUMN_NAME | String | The column name. |
GRANTOR | String | The object granting the access. |
GRANTEE | String | The object receiving the access. |
PRIVILEGE | String | The type of access granted. |
IS_GRANTABLE | String | Indicates if the grantee is allowed to grant access to other users. |
Note
For more information about the data returned by the getColumnPrivileges method, see "sp_column_privileges (Transact-SQL)" in [!INCLUDEssNoVersion] Books Online.
The following example demonstrates how to use the getColumnPrivileges method to return the access rights for the FirstName column in the Person.Contact table in the [!INCLUDEssSampleDBnormal] sample database.
public static void executeGetColumnPrivileges(Connection con) {
try {
DatabaseMetaData dbmd = con.getMetaData();
ResultSet rs = dbmd.getColumnPrivileges("AdventureWorks", "Person", "Contact", "FirstName");
ResultSetMetaData rsmd = rs.getMetaData();
// Display the result set data.
int cols = rsmd.getColumnCount();
while(rs.next()) {
for (int i = 1; i <= cols; i++) {
System.out.println(rs.getString(i));
}
}
rs.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
SQLServerDatabaseMetaData Methods
SQLServerDatabaseMetaData Members
SQLServerDatabaseMetaData Class