The Solution in Font

Drawing PDF-417 2d barcode in Font The Solution

The Solution
Encoding PDF-417 2d Barcode In None
Using Barcode encoder for Font Control to generate, create PDF-417 2d barcode image in Font applications.
www.OnBarcode.com
Making UCC - 12 In None
Using Barcode generation for Font Control to generate, create EAN128 image in Font applications.
www.OnBarcode.com
In our solution, we use the DatabaseMetaData.getTableTypes() method to solve the problem. This servlet (GetTableTypes) will display the result as XML or HTML.
Barcode Drawer In None
Using Barcode encoder for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
Encode EAN13 In None
Using Barcode creator for Font Control to generate, create EAN13 image in Font applications.
www.OnBarcode.com
CHAPTER 8 WEB ACCESS TO METADATA, PART 1
Generating UPC Code In None
Using Barcode maker for Font Control to generate, create UPC-A image in Font applications.
www.OnBarcode.com
Barcode Generator In None
Using Barcode generator for Font Control to generate, create Barcode image in Font applications.
www.OnBarcode.com
import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.List; import java.util.ArrayList; import java.io.PrintWriter; import java.io.IOException; import jcb.util.DatabaseUtil; import jcb.db.VeryBasicConnectionManager; public class GetTableTypes extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection conn = null; try { String dbVendor = request.getParameter("vendor").trim(); String outputFormat = request.getParameter("format").trim(); conn = VeryBasicConnectionManager.getConnection(dbVendor); List<String> tableTypes = getTableTypes(conn); if (outputFormat.equals("xml")) { printXML(response, tableTypes); } else { printHTML(response, tableTypes); } } catch(Exception e) { printError(response, e.getMessage()); } finally { DatabaseUtil.close(conn); } } // end doGet private static void printHTML(HttpServletResponse response, List<String> tableTypes) 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>Table Type</TH></TR>"); for (int i=0; i < tableTypes.size(); i++) {
PDF-417 2d Barcode Creator In None
Using Barcode printer for Font Control to generate, create PDF417 image in Font applications.
www.OnBarcode.com
Generating ISBN - 10 In None
Using Barcode printer for Font Control to generate, create International Standard Book Number image in Font applications.
www.OnBarcode.com
CHAPTER 8 WEB ACCESS TO METADATA, PART 1
Print PDF-417 2d Barcode In Java
Using Barcode maker for Java Control to generate, create PDF 417 image in Java applications.
www.OnBarcode.com
PDF 417 Creator In .NET
Using Barcode printer for ASP.NET Control to generate, create PDF 417 image in ASP.NET applications.
www.OnBarcode.com
buffer.append("<TR><TD>"); buffer.append(tableTypes.get(i)); buffer.append("</TD></TR>"); } buffer.append("</table></body></html>"); out.println(buffer.toString()); } private static void printXML(HttpServletResponse response, List<String> tableTypes) throws Exception { response.setContentType("text/xml"); PrintWriter out = response.getWriter(); StringBuilder buffer = new StringBuilder(); buffer.append("< xml version=\"1.0\" encoding=\"ISO-8859-1\" >"); buffer.append("<tableTypes>"); for (int i=0; i < tableTypes.size(); i++) { buffer.append("<type>"); buffer.append(tableTypes.get(i)); buffer.append("</type>"); } buffer.append("</tableTypes>"); 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 the table names for a given connection object. * @param conn the Connection object * @return the list of table names as a List. * @exception Failed to get the table names from the database. */ public static List<String> getTableTypes(Connection conn) throws Exception { ResultSet rs = null;
GTIN - 13 Encoder In None
Using Barcode maker for Online Control to generate, create EAN13 image in Online applications.
www.OnBarcode.com
Create EAN-13 Supplement 5 In Java
Using Barcode generator for BIRT reports Control to generate, create UPC - 13 image in BIRT reports applications.
www.OnBarcode.com
CHAPTER 8 WEB ACCESS TO METADATA, PART 1
Barcode Encoder In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
EAN128 Encoder In C#
Using Barcode encoder for VS .NET Control to generate, create EAN / UCC - 14 image in .NET applications.
www.OnBarcode.com
try { DatabaseMetaData meta = conn.getMetaData(); if (meta == null) { return null; } rs = meta.getTableTypes(); if (rs == null) { return null; } List<String> list = new ArrayList<String>(); System.out.println("getTableTypes(): --------------"); while (rs.next()) { String type = rs.getString(1); System.out.println("type="+type); if (type != null) { list.add(type); } } System.out.println("--------------"); return list; } finally { DatabaseUtil.close(rs); } } }
Denso QR Bar Code Creation In Visual C#
Using Barcode drawer for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
EAN 13 Encoder In .NET
Using Barcode maker for ASP.NET Control to generate, create EAN-13 image in ASP.NET applications.
www.OnBarcode.com
Invoking GetTableTypes for MySQL
Print GTIN - 12 In Java
Using Barcode generator for BIRT Control to generate, create UPC Symbol image in BIRT reports applications.
www.OnBarcode.com
Printing UPC Symbol In Objective-C
Using Barcode maker for iPad Control to generate, create GS1 - 12 image in iPad applications.
www.OnBarcode.com
Figure 8-8 shows how to run the solution for the MySQL database.
Barcode Drawer In None
Using Barcode maker for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
Encoding GS1 - 12 In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create GTIN - 12 image in VS .NET applications.
www.OnBarcode.com
Figure 8-8. Invoking GetTableTypes for MySQL (XML output)
CHAPTER 8 WEB ACCESS TO METADATA, PART 1
Invoking GetTableTypes for Oracle
Figure 8-9 shows how to run the solution for the Oracle database.
Figure 8-9. Invoking GetTableTypes for Oracle (XML output)
8.10. How Do You Get a List of Table Names for a Database
Each database has a finite set of tables, views, and other objects (such as indexes and stored procedures). JDBC enables you to get a list of tables for a specific database. You can use DatabaseMetaData.getTables() to retrieve a description of the tables available in the given catalog (database). Only table descriptions matching the catalog, schema, table name, and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM, and TABLE_NAME. The signature of DatabaseMetaData.getTables() is ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException This method returns the result as a ResultSet object, which is not very useful for web-based applications. Therefore, we will convert the ResultSet object to HTML or XML, which can be quite useful to web-based applications. I present a Java servlet (GetTables), which will be able to get table names (plus other metadata information) as HTML or XML. Here is the signature of the servlet: GetTables vendor=<vendor-name>&format=<HTML-or-XML> You may add additional parameters to suit your database application. Here, I use vendor to act as a database selector. So, to get the table information as XML for a MySQL database, you may invoke it as GetTables vendor=mysql&format=xml GetTables vendor=mysql&format=html GetTables vendor=oracle&format=xml GetTables vendor=oracle&format=html
CHAPTER 8 WEB ACCESS TO METADATA, PART 1
MySQL Database Setup
mysql> use octopus; Database changed mysql> show tables; +--------------------+ | Tables_in_octopus | +--------------------+ | departments | | employees | | employees_original | | test | | test1 | | test2 | +--------------------+ 6 rows in set (0.00 sec)
Oracle Database Setup
$ sqlplus.exe scott/tiger SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 20 20:19:45 2005 Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production SQL> select object_name from user_objects where object_type = 'TABLE'; OBJECT_NAME ----------DEPT EMP BONUS SALGRADE
Copyright © OnBarcode.com . All rights reserved.