ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/microjdbcmecon.htm

99 lines
5.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="reference" />
<meta name="DC.Title" content="Using ToolboxME for iSeries to connect to a database on the host server" />
<meta name="abstract" content="" />
<meta name="description" content="" />
<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="microjdbcmecon" />
<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>Using ToolboxME for iSeries to connect to a database on the host server</title>
</head>
<body id="microjdbcmecon"><a name="microjdbcmecon"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Using ToolboxME for iSeries to connect to a database on the host server</h1>
<div><p></p>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/micro/JdbcMeConnection.html#NAVBAR_TOP">JdbcMeConnection class</a> provides a subset of functions
available in the IBM<sup>®</sup> Toolbox for Java™ <a href="javadoc/com/ibm/as400/access/AS400JDBCConnection.html">AS400JDBCConnection class</a>. Use JdbcMeConnection to enable
your <a href="microconcept.htm#microconcept__tier0">Tier0</a> device
to access DB2
Universal Database™ (UDB) databases on the host server.</p>
<div class="note"><span class="notetitle">Note:</span> To use
ToolboxMe for iSeries™ classes,
you must separately download and set up the ToolboxME for iSeries component.
For more information, see <a href="microrequire.htm#microrequire">ToolboxME
for iSeries requirements
and installation</a>.</div>
<p>Use <a href="javadoc/com/ibm/as400/micro/JdbcMeDriver.html#GETCONNECTION(JAVA.LANG.STRING)">JdbcMeDriver.getConnection()</a> to connect to the server
database. The getConnection() method takes a uniform resource locator (URL)
string as an argument, the user ID, and password. The JDBC driver manager
on the host server attempts to locate a driver that can connect to the database
that is represented by the URL. JdbcMeDriver uses the following syntax for
the URL:</p>
<pre> jdbc:as400://server-name/default-schema;meserver=&lt;server&gt;[:port];[other properties];</pre>
<div class="note"><span class="notetitle">Note:</span> The
previous syntax example is on two lines so you can easily see and print it.
Normally, the URL appears on one line with no breaks or extra spaces.</div>
<p>You
must specify a server name, or JdbcMeDriver throws an exception. The default
schema is optional. If you do not specify a port, the JdbcMeDriver uses port
3470. Also, you can set a variety of JDBC properties within the URL. To set
properties, use the following syntax:</p>
<pre> name1=value1;name2=value2;...</pre>
<p>See <a href="jdbcproperties.htm#jdbcproperties">JDBC properties</a> for a complete
list of properties supported by JdbcMeDriver.</p>
</div>
<div class="section"><h4 class="sectiontitle">Examples: Using the JdbcMeDriver to connect to a server</h4><p><strong>Example:
Connecting to the server database without specifying a default schema, a
port, or JDBC properties</strong></p>
<p>The examples specifies user ID and password
as parameters on the method:</p>
<pre> // Connect to system 'mysystem'. No default schema, port or
// properties are specified.
Connection c = JdbcMeDriver.getConnection("jdbc:as400://mysystem.helloworld.com;meserver=myMeServer;"
"auser",
"apassword");</pre>
<p><strong>Example:
Connecting to the server database when specifying the schema and JDBC properties</strong></p>
<p>The
example specifies user ID and password as parameters on the method:</p>
<pre> // Connect to system 'mysystem'. Specify a schema and
// two JDBC properties. Do not specify a port.
Connection c2 = JdbcMeDriver.getConnection(
"jdbc:as400://mysystem.helloworld.com/mySchema;meserver=myMeServer;naming=system;errors=full;"
"auser",
"apassword");</pre>
<p><strong>Example: Connecting to the server database</strong></p>
<p>The
example specifies properties (including user ID and password) by using a
uniform resource locator (URL):</p>
<pre> // Connect using properties. The properties are set on the URL
// instead of through a properties object.
Connection c = DriverManager.getConnection(
"jdbc:as400://mySystem;meserver=myMeServer;naming=sql;errors=full;user=auser;password=apassword");
</pre>
<p><strong>Example: Disconnecting from the database</strong></p>
<p>The
example uses the close() method on the connecting object to disconnect from
the server:</p>
<pre> c.close();</pre>
</div>
</div>
</body>
</html>