c# barcode reader library WEB ACCESS TO METADATA, PART 2 in Font

Maker PDF 417 in Font WEB ACCESS TO METADATA, PART 2

CHAPTER 9 WEB ACCESS TO METADATA, PART 2
Creating PDF417 In None
Using Barcode maker for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
Barcode Maker In None
Using Barcode printer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
getTablePrivileges() returns only privileges that match the schema and table name criteria. They are ordered by TABLE_SCHEM, TABLE_NAME, and PRIVILEGE. Each privilege description has the columns shown in Table 9-5. Table 9-5. Result Columns for Invoking getTablePrivileges()
EAN13 Generator In None
Using Barcode generation for Font Control to generate, create EAN13 image in Font applications.
www.OnBarcode.com
Make Quick Response Code In None
Using Barcode encoder for Font Control to generate, create QR Code image in Font applications.
www.OnBarcode.com
Column s Position
Barcode Creator In None
Using Barcode printer for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Code-128 Generation In None
Using Barcode creator for Font Control to generate, create Code 128 Code Set C image in Font applications.
www.OnBarcode.com
1 2 3 4 5 6 7
Drawing UCC - 12 In None
Using Barcode generation for Font Control to generate, create UCC-128 image in Font applications.
www.OnBarcode.com
Print Uniform Symbology Specification ITF In None
Using Barcode generator for Font Control to generate, create ANSI/AIM ITF 25 image in Font applications.
www.OnBarcode.com
Name
Decoding PDF-417 2d Barcode In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
PDF-417 2d Barcode Scanner In Visual Basic .NET
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
TABLE_CAT TABLE_SCHEM TABLE_NAME GRANTOR GRANTEE PRIVILEGE IS_GRANTABLE
Generating QR Code In Java
Using Barcode creator for BIRT reports Control to generate, create QR Code ISO/IEC18004 image in BIRT applications.
www.OnBarcode.com
Linear Barcode Creator In VB.NET
Using Barcode creator for .NET framework Control to generate, create Linear image in Visual Studio .NET applications.
www.OnBarcode.com
Type
Drawing Code-39 In C#.NET
Using Barcode generator for Visual Studio .NET Control to generate, create Code39 image in .NET applications.
www.OnBarcode.com
Creating ANSI/AIM Code 39 In Java
Using Barcode creation for BIRT reports Control to generate, create ANSI/AIM Code 39 image in BIRT applications.
www.OnBarcode.com
String String String String String String String
Printing QR Code ISO/IEC18004 In .NET
Using Barcode encoder for Reporting Service Control to generate, create QR image in Reporting Service applications.
www.OnBarcode.com
Code128 Reader In None
Using Barcode recognizer for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Description
Data Matrix Encoder In .NET Framework
Using Barcode creator for Reporting Service Control to generate, create Data Matrix image in Reporting Service applications.
www.OnBarcode.com
Encoding QR Code In Java
Using Barcode encoder for Java Control to generate, create QR Code image in Java applications.
www.OnBarcode.com
Table catalog (may be null) Table schema (may be null) Table name (as a String) Grantor of access (may be null) Grantee of access Name of access (SELECT, INSERT, UPDATE, REFRENCES, etc.) YES if grantee is permitted to grant to others; NO if not; null if unknown
Decode ANSI/AIM Code 128 In .NET Framework
Using Barcode scanner for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Code 128 Code Set B Encoder In None
Using Barcode drawer for Microsoft Word Control to generate, create USS Code 128 image in Word applications.
www.OnBarcode.com
The getTablePrivileges() method has the following signature: public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws java.sql.SQLException where catalog is a catalog name; "" retrieves those without a catalog. schemaPattern is a schema name pattern; "" retrieves those without a schema. tableNamePattern is a table name pattern. Next we ll look at a Java servlet, GetTablePrivileges, which has the following signature: GetTablePrivileges vendor=<db-vendor>& catalog=<catalog-name>& schema=<schema-name>& table=<table-pattern>& format=<xml/html>
The Solution
import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.PrintWriter; import java.io.IOException;
CHAPTER 9 WEB ACCESS TO METADATA, PART 2
import jcb.util.DatabaseUtil; import jcb.db.VeryBasicConnectionManager; public class GetTablePrivileges extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ResultSet tablePrivileges = null; Connection conn = null; try { String dbVendor = request.getParameter("vendor").trim(); String outputFormat = request.getParameter("format").trim(); String table = request.getParameter("table").trim(); conn = VeryBasicConnectionManager.getConnection(dbVendor); if (dbVendor.equals("mysql")) { //String catalog = request.getParameter("catalog").trim(); tablePrivileges = getTablePrivileges(conn, conn.getCatalog(), // catalog, null, // schema Pattern, "%"); // table. Pattern } else if (dbVendor.equals("oracle")) { //String schema = request.getParameter("schema").trim(); tablePrivileges = getTablePrivileges(conn, conn.getCatalog(), // catalog "%", // schema Pattern, table+"%"); // table. Pattern } else { printError(response, "unknown db vendor"); return; } if (outputFormat.equals("xml")) { printXML(response, tablePrivileges); } else { printHTML(response, tablePrivileges); } } catch(Exception e) { e.printStackTrace(); printError(response, e.getMessage()); }
CHAPTER 9 WEB ACCESS TO METADATA, PART 2
finally { DatabaseUtil.close(tablePrivileges); DatabaseUtil.close(conn); } } // end doGet private static void printHTML(HttpServletResponse response, ResultSet tablePrivileges) throws Exception { response.setContentType("text/html"); PrintWriter out = response.getWriter(); StringBuilder buffer = new StringBuilder(); buffer.append("<html><body><table border=1 cellspacing=0 cellpadding=0>"); buffer.append("<TR><TH>Catalog</TH>"); buffer.append("<TH>Schema</TH>"); buffer.append("<TH>Table Name</TH>"); buffer.append("<TH>Grantor</TH>"); buffer.append("<TH>Grantee</TH>"); buffer.append("<TH>Privilege</TH>"); buffer.append("<TH>Is Grantable</TH></TR>"); while (tablePrivileges.next()) { buffer.append("<TR><TD>"); buffer.append(tablePrivileges.getString("TABLE_CAT")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("TABLE_SCHEM")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("TABLE_NAME")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("GRANTOR")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("GRANTEE")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("PRIVILEGE")); buffer.append("</TD><TD>"); buffer.append(tablePrivileges.getString("IS_GRANTABLE")); buffer.append("</TD></TR>"); } buffer.append("</table></body></html>"); out.println(buffer.toString()); } private static void printXML(HttpServletResponse response, ResultSet tablePrivileges) throws Exception { response.setContentType("text/xml"); PrintWriter out = response.getWriter();
CHAPTER 9 WEB ACCESS TO METADATA, PART 2
StringBuilder buffer = new StringBuilder(); buffer.append("< xml version=\"1.0\" >"); buffer.append("<table_privileges>"); while (tablePrivileges.next()) { buffer.append("<table_privilege><catalog>"); buffer.append(tablePrivileges.getString("TABLE_CAT")); buffer.append("</catalog><schema>"); buffer.append(tablePrivileges.getString("TABLE_SCHEM")); buffer.append("</schema><tableName>"); buffer.append(tablePrivileges.getString("TABLE_NAME")); buffer.append("</tableName><grantor>"); buffer.append(tablePrivileges.getString("GRANTOR")); buffer.append("</grantor><grantee>"); buffer.append(tablePrivileges.getString("GRANTEE")); buffer.append("</grantee><privilege>"); buffer.append(tablePrivileges.getString("PRIVILEGE")); buffer.append("</privilege><is_grantable>"); buffer.append(tablePrivileges.getString("IS_GRANTABLE")); buffer.append("</is_grantable></table_privilege>"); } buffer.append("</table_privileges>"); out.println(buffer.toString()); } private static void printError(HttpServletResponse response, String message) { try { PrintWriter out = response.getWriter(); StringBuffer buffer = new StringBuffer(); buffer.append("<html><body>"); buffer.append(message); buffer.append("</body></html>"); out.println(buffer); } catch(Exception ignore) { } }
/** * Get Table Privileges: retrieves a description of the access * rights for each table available in a catalog. Note that a * table privilege applies to one or more tablePrivileges in the table. * It would be wrong to assume that this privilege applies to * all tablePrivileges (this may be true for some systems but is not * true for all.) The result is returned as a ResultSet object. *
CHAPTER 9 WEB ACCESS TO METADATA, PART 2
* In JDBC, Each privilege description has the following tablePrivileges: * * TABLE_CAT String => table catalog (may be null) * TABLE_SCHEM String => table schema (may be null) * TABLE_NAME String => table name * GRANTOR => grantor of access (may be null) * GRANTEE String => grantee of access * PRIVILEGE String => name of access (SELECT, INSERT, * UPDATE, REFERENCES, ...) * IS_GRANTABLE String => "YES" if grantee is permitted to grant * to others; "NO" if not; null if unknown * * * @param conn the Connection object * @param catalogPattern a catalog pattern. * @param schemaPattern a schema pattern. * @param tableNamePattern a table name pattern; must match * the table name as it is stored in the database. * @return a ResultSet object * @exception Failed to get the Get Table Privileges. */ public static ResultSet getTablePrivileges(Connection conn, String catalog, String schemaPattern, String tableNamePattern) throws Exception { if ((tableNamePattern == null) || (tableNamePattern.length() == 0)) { return null; } DatabaseMetaData meta = conn.getMetaData(); if (meta == null) { return null; } // The '_' character represents any single character. // The '%' character represents any sequence of zero // or more characters. return meta.getTablePrivileges(catalog, schemaPattern, tableNamePattern); } }
Copyright © OnBarcode.com . All rights reserved.