65 lines
4.1 KiB
HTML
65 lines
4.1 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
|
||
|
|
||
|
<title><tsx:dbconnect></title>
|
||
|
</head>
|
||
|
|
||
|
<BODY>
|
||
|
<!-- Java sync-link -->
|
||
|
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
|
||
|
|
||
|
<h5><a name="jspcon"></a><tsx:dbconnect></h5>
|
||
|
|
||
|
<p>Use the <tsx:dbconnect> syntax to specify information needed to make a connection to a JDBC-accessible database. The <tsx:dbconnect> syntax does not establish the connection. Instead, the <tsx:dbquery> and <tsx:dbmodify> syntax are used to reference a <tsx:dbconnect> in the same JSP file and establish the connection.</p>
|
||
|
|
||
|
<p>When the JSP file is compiled into a servlet, the Java processor adds the Java coding for the <tsx:dbconnect> syntax to the servlet's service() method, which means a new database connection is created for each request for the JSP file.</p>
|
||
|
|
||
|
|
||
|
<p>The <tsx:dbconnect> syntax is:</p>
|
||
|
|
||
|
<pre><tsx:dbconnect id="<em>connection_id</em>" userid="<em>db_user</em>" passwd="<em>user_password</em>"
|
||
|
url="jdbc:<em>subprotocol</em>:<em>database</em>" driver="<em>database_driver_name</em>"
|
||
|
jndiname="<em>JNDI_context/logical name</em>">
|
||
|
</tsx:dbconnect></pre>
|
||
|
|
||
|
<p>This describes the attributes and their values:</p>
|
||
|
|
||
|
<ul>
|
||
|
<li><p><strong>id</strong>
|
||
|
<br>A required identifier. The scope is the JSP file. This identifier is referenced by the connection attribute of a <tsx:dbquery> tag.</p></li>
|
||
|
|
||
|
<li><p><strong>userid</strong>
|
||
|
<br>An optional attribute that specifies a valid user ID for the database to be accessed. If specified, this attribute and its value are added to the request object.</p>
|
||
|
|
||
|
<p>Although the userid attribute is an optional tag attribute, you must provide a user ID for this tag, either with the attribute or by using the nested tag <tsx:userid>. See <a href="jspidp.htm"><tsx:userid> and <tsx:passwd></a> for an alternative to hardcoding this information in the JSP file.</p></li>
|
||
|
|
||
|
<li><p><strong>passwd</strong>
|
||
|
<br>An optional attribute that specifies the user password for the userid attribute. (This attribute is not optional if the userid attribute is specified.) If specified, this attribute and its value are added to the request object.</p>
|
||
|
|
||
|
<p>Although the passwd attribute is optional, you must provide a password for this tag, either with the attribute or by using the <tsx:passwd> tag. See <a href="jspidp.htm"><tsx:userid> and <tsx:passwd></a> for an alternative to hardcoding this attribute in the JSP file.</p></li>
|
||
|
|
||
|
<li><p><strong>url</strong> and <strong>driver</strong>
|
||
|
<br>To establish a database connection, the URL and driver must be provided.</p>
|
||
|
|
||
|
<p>The url attribute specifies the location of the database. The driver attribute specifies the name of the driver to be used to establish the database connection.</p>
|
||
|
|
||
|
<p>For a connection to a JDBC-accessible database, the URL consists of these colon-separated elements: jdbc, the subprotocol name, and the name of the database to be accessed. For example:</p>
|
||
|
|
||
|
<pre>url="jdbc:db2:*local"
|
||
|
driver="com.ibm.db2.jdbc.app.DB2Driver"</pre></li>
|
||
|
|
||
|
<li><p><strong>jndiname</strong>
|
||
|
<br>This optional attribute identifies a valid context in the WebSphere Application Server - Express JNDI naming context and the logical name of the data source in that context. The context is configured by the Web administrator using an administrative client such as the WebSphere administrative console.</p></li>
|
||
|
</ul>
|
||
|
|
||
|
<p>All of the elements shown in the example need to be specified. However, an empty element (such as <url></url>) is valid.</p>
|
||
|
|
||
|
<p>When the JSP file is compiled into a servlet, the Java processor adds the Java coding for the <tsx:dbconnect> syntax to the servlet's service() method, which means a new database connection is created for each request for the JSP file.</p>
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|