Get Column Privileges

From Java Example Source Code

Jump to: navigation, search

4U3Kkz <a href="http://hewwsjxafkag.com/">hewwsjxafkag</a>, [url=http://eahfiqigldie.com/]eahfiqigldie[/url], [link=http://iohzdepcimrk.com/]iohzdepcimrk[/link], http://yeaouwlksstz.com/

Contents

[edit] Java Source Code

  • Package: example.jdbc.privileges
  • File: GetColumnPrivilegesOracle.java
package example.jdbc.privileges;
 
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
 
public class GetColumnPrivilegesOracle {
    public static void main(String[] args) throws Exception {
	Connection conn = null;
 
	conn = getConnection();
	String catalogPattern = conn.getCatalog();
	String schemaPattern = "SYSTEM";
	String tableNamePattern = "HELP";
 
	ResultSet privileges = null;
	DatabaseMetaData meta = conn.getMetaData();
 
	// The '_' character represents any single character.
	// The '%' character represents any sequence of zero or more characters.
	privileges = meta.getTablePrivileges(catalogPattern, schemaPattern, tableNamePattern);
	while (privileges.next()) {
 
	    String catalog = privileges.getString("TABLE_CAT");
	    String schema = privileges.getString("TABLE_SCHEM");
	    String tableName = privileges.getString("TABLE_NAME");
	    String privilege = privileges.getString("PRIVILEGE");
	    String grantor = privileges.getString("GRANTOR");
	    String grantee = privileges.getString("GRANTEE");
	    String isGrantable = privileges.getString("IS_GRANTABLE");
 
	    System.out.println("table name:" + tableName);
	    System.out.println("catalog:" + catalog);
	    System.out.println("schema:" + schema);
	    System.out.println("privilege:" + privilege);
	    System.out.println("grantor:" + grantor);
	    System.out.println("isGrantable:" + isGrantable);
	    System.out.println("grantee:" + grantee);
	    conn.close();
 
	}
    }
 
    public static Connection getConnection() throws Exception {
	String driver = "oracle.jdbc.driver.OracleDriver";
	String url = "jdbc:oracle:thin:@localhost:1521:databaseName";
	String username = "system";
	String password = "password";
	Class.forName(driver); // load Oracle driver
	return DriverManager.getConnection(url, username, password);
    }
 
}

[edit] What Result You Can Get

Coming soon... Run the program, you will get:

Replace with the result of you Java program.

[edit] Required External Libraries and/or Files for this Java Example

In order to run this Java example, one of the following libraries may be required: In order to run this example program, one of the following libraries may be required:

http://www.bowlinginlubbock.com/Prednisone_Orders.htm prednisone online 700088 http://www.perrysmusic.com/valiumonline.htm valium >:]]] http://www.paesine.com/ambien.html ambien 2485 http://www.santiliebana.com/ tramadol vnsrf

[edit] Question & Answer

Any question?

Click edit and post your question or answer here.


Personal tools