ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/datameta.htm

156 lines
9.6 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="DatabaseMetaData interface for IBM Developer Kit for Java" />
<meta name="abstract" content="The DatabaseMetaData interface is implemented by the IBM Developer Kit for Java JDBC driver to provide information about its underlying data sources. It is used primarily by application servers and tools to determine how to interact with a given data source. Applications may also use DatabaseMetaData methods to obtain information about a data source, but this is less typical." />
<meta name="description" content="The DatabaseMetaData interface is implemented by the IBM Developer Kit for Java JDBC driver to provide information about its underlying data sources. It is used primarily by application servers and tools to determine how to interact with a given data source. Applications may also use DatabaseMetaData methods to obtain information about a data source, but this is less typical." />
<meta name="DC.Relation" scheme="URI" content="jdbc.htm" />
<meta name="DC.Relation" scheme="URI" content="dataex.htm" />
<meta name="DC.Relation" scheme="URI" content="safegetudts.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="datameta" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>DatabaseMetaData interface for IBM Developer Kit for Java</title>
</head>
<body id="datameta"><a name="datameta"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">DatabaseMetaData interface for IBM Developer Kit for Java</h1>
<div><p>The DatabaseMetaData interface is implemented by the IBM<sup>®</sup> Developer
Kit for Java™ JDBC driver to provide information about its underlying
data sources. It is used primarily by application servers and tools to determine
how to interact with a given data source. Applications may also use DatabaseMetaData
methods to obtain information about a data source, but this is less typical.</p>
<p>The DatabaseMetaData interface includes over 150 methods that can be categorized
according to the types of information they provide. These are described below.
The DatabaseMetaData interface also contains over 40 fields that are constants
used as return values for various DatabaseMetaData methods.</p>
<p>See "Changes in JDBC 3.0" below for information about changes made to methods
in the DatabaseMetaData interface.</p>
<div class="section"><h4 class="sectiontitle">Create a DatabaseMetaData object</h4><p>A DatabaseMetaData
object is created with the Connection method getMetaData. Once the object
is created, it can be used to dynamically find information about the underlying
data source. The following example creates a DatabaseMetaData object and uses
it to determine the maximum number of characters allowed for a table name:</p>
<p><strong>Example:</strong> Create
a DatabaseMetaData object</p>
<div class="note"><span class="notetitle">Note:</span> Read the <a href="codedisclaimer.htm">Code
example disclaimer</a> for important legal information.</div>
<blockquote><pre>// con is a Connection object
DatabaseMetaData dbmd = con.getMetadata();
int maxLen = dbmd.getMaxTableNameLength();</pre>
</blockquote>
</div>
<div class="section"><h4 class="sectiontitle">Retrieve general information</h4><p>Some DatabaseMetaData
methods are used to dynamically find general information about a data source
as well as to obtain details about its implementation. Some of these methods
include the following:</p>
<ul><li>getURL</li>
<li>getUserName</li>
<li>getDatabaseProductVersion, getDriverMajorVersion, and getDriverMinorVersion</li>
<li>getSchemaTerm, getCatalogTerm, and getProcedureTerm</li>
<li>nullsAreSortedHigh, and nullsAreSortedLow</li>
<li>usesLocalFiles, and usesLocalFilePerTable</li>
<li>getSQLKeywords</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Determine feature support</h4><p>A large group of DatabaseMetaData
methods can be used to determine whether a given feature or set of features
is supported by the driver or underlying data source. Beyond this, there are
methods that describe what level of support is provided. Some of the methods
that describe support for individual features include the following:</p>
<ul><li>supportsAlterTableWithDropColumn</li>
<li>supportsBatchUpdates</li>
<li>supportsTableCorrelationNames</li>
<li>supportsPositionedDelete</li>
<li>supportsFullOuterJoins</li>
<li>supportsStoredProcedures</li>
<li>supportsMixedCaseQuotedIdentifiers</li>
</ul>
<p>Methods to describe a level of feature support include the following:</p>
<ul><li>supportsANSI92EntryLevelSQL</li>
<li>supportsCoreSQLGrammar</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Data source limits</h4><p>Another group of methods provide
the limits imposed by a given data source. Some of the methods in this category
include the following:</p>
<ul><li>getMaxRowSize</li>
<li>getMaxStatementLength</li>
<li>getMaxTablesInSelect</li>
<li>getMaxConnections</li>
<li>getMaxCharLiteralLength</li>
<li>getMaxColumnsInTable</li>
</ul>
<p>Methods in this group return the limit value as an integer. A return
value of zero means that there is either no limit or the limit is unknown.</p>
</div>
<div class="section"><h4 class="sectiontitle">SQL objects and their attributes</h4><p>A number of DatabaseMetaData
methods provide information about the SQL objects that populate a given data
source. These methods can determine the attributes of SQL objects. These methods
also return ResultSet objects in which each row describes a particular object.
For example, the getUDTs method returns a ResultSet object in which there
is a row for each user-defined table (UDT) that has been defined in the data
source. Examples of this category include the following:</p>
<ul><li>getSchemas and getCatalogs</li>
<li>getTables</li>
<li>getPrimaryKeys</li>
<li>getProcedures and getProcedureColumns</li>
<li>getUDTs</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Transaction support</h4><p>A small group of methods provide
information about the transaction semantics supported by the data source.
Examples of this category include the following:</p>
<ul><li>supportsMultipleTransactions</li>
<li>getDefaultTransactionIsolation</li>
</ul>
<p>See <a href="dataex.htm">Example: DatabaseMetaData interface for IBM Developer
Kit for Java</a> for an example of how to use the DatabaseMetaData
interface.</p>
</div>
<div class="section"><h4 class="sectiontitle">Changes in JDBC 3.0</h4><p> There are changes to the return
values for some of the methods in JDBC 3.0. The following methods have been
updated in JDBC 3.0 to add fields to the ResultSets that they return.</p>
<ul><li>getTables</li>
<li>getColumns</li>
<li>getUDTs</li>
<li>getSchemas</li>
</ul>
<div class="note"><span class="notetitle">Note:</span> If an application is being developed using Java Development
Kit (JDK) 1.4, you may recognize that there are a certain number of columns
being returned when testing. You write your application and expect to access
all of these columns. However, if the application is being designed to also
run on previous releases of the JDK, the application receives an SQLException
when it tries to access these fields that do not exist in earlier JDK releases. <a href="safegetudts.htm">SafeGetUDTs</a> is an example of how an application
can be written to work with several JDK releases.</div>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="dataex.htm">Example: DatabaseMetaData interface for IBM Developer Kit for Java - Return a list of tables</a></strong><br />
This example shows how to return a list of tables.</li>
<li class="ulchildlink"><strong><a href="safegetudts.htm">Example: Use metadata ResultSets that have more than one column</a></strong><br />
This is an example of how to use metadata ResultSets that have more than one column.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="jdbc.htm" title="The IBM Developer Kit for Java JDBC driver, also known as the &#34;native&#34; driver, provides programmatic access to iSeries database files. Using the Java Database Connectivity (JDBC) API, applications written in the Java language can access JDBC database functions with embedded Structured Query Language (SQL), run SQL statements, retrieve results, and propagate changes back to the database. The JDBC API can also be used to interact with multiple data sources in a distributed, heterogeneous environment.">Access your iSeries database with the IBM Developer Kit for Java JDBC driver</a></div>
</div>
</div>
</body>
</html>