⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmp5.html

📁 j2eePDF格式的电子书
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  <head>    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />    <meta http-equiv="Content-Style-Type" content="text/css" />    <title>Building and Running the RosterApp Example</title>    <link rel="StyleSheet" href="document.css" type="text/css" media="all" />    <link rel="StyleSheet" href="catalog.css" type="text/css" media="all" />    <link rel="Table of Contents" href="J2EETutorialTOC.html" />    <link rel="Previous" href="CMP4.html" />    <link rel="Next" href="CMP6.html" />    <link rel="Index" href="J2EETutorialIX.html" />  </head>  <body>    <table width="550" summary="layout" id="SummaryNotReq1">      <tr>	<td align="left" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/download.html#tutorial" target="_blank">Download</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/faq.html" target="_blank">FAQ</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/history.html" target="_blank">History</a>	</td>        <td align="center" valign="center"><a accesskey="p" href="CMP4.html"><img id="LongDescNotReq1" src="images/PrevArrow.gif" width="26" height="26" border="0" alt="Prev" /></a><a accesskey="c" href="J2EETutorialFront.html"><img id="LongDescNotReq1" src="images/UpArrow.gif" width="26" height="26" border="0" alt="Home" /></a><a accesskey="n" href="CMP6.html"><img id="LongDescNotReq3" src="images/NextArrow.gif" width="26" height="26" border="0" alt="Next" /></a><a accesskey="i" href="J2EETutorialIX.html"></a>        </td>	<td align="right" valign="center">	<font size="-1">	<a href="http://java.sun.com/j2ee/1.4/docs/api/index.html" target="_blank">API</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/search.html" target="_blank">Search</a>	<br>	<a href="http://java.sun.com/j2ee/1.4/docs/tutorial/information/sendusmail.html" target="_blank">Feedback</a></font>	</font>	</td>      </tr>    </table>    <img src="images/blueline.gif" width="550" height="8" ALIGN="BOTTOM" NATURALSIZEFLAG="3" ALT="Divider">    <blockquote><a name="wp82939"> </a><h2 class="pHeading1">Building and Running the RosterApp Example</h2><a name="wp82940"> </a><p class="pBody">Now that you understand the structure of the RosterApp example EAR file, you will assemble the enterprise application, the application client, and run the example. This section gives detailed instructions on how to build and run the RosterApp example located at <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/cmproster/</code>. </p><a name="wp82942"> </a><h3 class="pHeading2">Creating the Database Tables</h3><a name="wp81004"> </a><p class="pBody">The instructions that follow explain how to use the <code class="cCode">RosterApp</code> example with PointBase, the database software that is included in the J2EE Application Server bundle. </p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81010"> </a><div class="pSmartList1"><li>Start the PointBase server. For instructions, see <a  href="WebApp13.html#wp83431">Starting the PointBase Database Server</a>.</li></div><a name="wp81013"> </a><div class="pSmartList1"><li>Create the database tables by running the <code class="cCode">create.sql</code> script.</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81014"> </a><div class="pSmartList2"><li>In a terminal window, go to this directory:</li></div><a name="wp81015"> </a><p class="pBodyRelative"><code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/cmproster/</code> </p><a name="wp81016"> </a><div class="pSmartList2"><li>Type the following command, which runs the <code class="cCode">create.sql </code>script:</li></div><a name="wp81017"> </a><p class="pBodyRelative"><code class="cCode">asant create-db_common</code> </p></ol></div></ol></div><a name="wp80968"> </a><h3 class="pHeading2">Creating the JDBC Resource</h3><a name="wp82748"> </a><p class="pBody">You must create the <code class="cCode">jdbc/ejbTutorialDB</code> resource. For instructions on creating this resource in the Admin Console, see <a  href="Resources4.html#wp81695"></a><a  href="Resources4.html#wp81695">Defining a Data Source in the J2EE Application Server</a>.</p><a name="wp82747"> </a><h3 class="pHeading2">Capturing the Table Schema</h3><a name="wp81028"> </a><p class="pBody">You will now create a database schema file, which will allow you to map fields from the enterprise beans to columns in the database tables created above.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81029"> </a><div class="pSmartList1"><li>Make sure the PointBase server is running.</li></div><a name="wp81033"> </a><div class="pSmartList1"><li>In a terminal window, go to:</li></div><a name="wp81034"> </a><p class="pBodyRelative"><code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/cmproster/</code></p><a name="wp81063"> </a><div class="pSmartList1"><li>Type the following command to create the database schema file, named <code class="cCode">cmproster.dbschema</code>, in the .<code class="cCode">/build/</code> directory:</li></div><a name="wp81082"> </a><p class="pBodyRelative"><code class="cCode">asant capture-db-schema</code></p></ol></div><a name="wp81089"> </a><p class="pBody">The <code class="cCode">capture-db-schema</code> task calls the <code class="cCode">capture-schema</code> utility to output an XML file, <code class="cCode">cmproster.dbschema</code>, that represents the structure of the database tables created in <a  href="CMP5.html#wp82942">Creating the Database Tables</a> above. <code class="cCode">cmproster.dbschema</code> will be used to automatically map the enterprise bean fields to database columns.</p><a name="wp83558"> </a><p class="pBody">The command that's called when you run the capture-db-schema task is as follows:</p><div class="pPreformattedRelative"><pre class="pPreformattedRelative">capture-schema -dburl jdbc:pointbase:server://localhost:9092/sun-appserv-samples -username pbpublic -password pbpublic -table LEAGUE -table PLAYER -table TEAM -table TEAM_PLAYER -schemaname PBPUBLIC -driver com.pointbase.jdbc.jdbcUniversalDriver -out build/cmproster.dbschema<a name="wp83579"> </a></pre></div><a name="wp83580"> </a><h3 class="pHeading2">Building the Enterprise Beans</h3><a name="wp81124"> </a><p class="pBody">You will now build the enterprise beans.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81118"> </a><div class="pSmartList1"><li>In a terminal window, go to this directory:</li></div><a name="wp81119"> </a><p class="pBodyRelative"><code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/cmproster/</code> </p><a name="wp81120"> </a><div class="pSmartList1"><li>Type the following command:</li></div><a name="wp81121"> </a><p class="pBodyRelative"><code class="cCode">asant build</code></p></ol></div><a name="wp80970"> </a><h3 class="pHeading2">Creating the Enterprise Application</h3><a name="wp81111"> </a><p class="pBody">Create a new application in deploytool called <code class="cCode">RosterApp</code>.</p><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp82844"> </a><div class="pSmartList1"><li>In deploytool select File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Application.</li></div><a name="wp82848"> </a><div class="pSmartList1"><li>In the Application File Name field click Browse.</li></div><a name="wp82849"> </a><div class="pSmartList1"><li>Navigate to <code class="cCode">&lt;</code><code class="cVariable">INSTALL</code><code class="cCode">&gt;/j2eetutorial14/examples/ejb/cmproster/</code>.</li></div><a name="wp82856"> </a><div class="pSmartList1"><li>In the File Name field enter <code class="cCode">RosterApp</code>.</li></div><a name="wp82860"> </a><div class="pSmartList1"><li>Click New Application.</li></div><a name="wp82867"> </a><div class="pSmartList1"><li>Click OK.</li></div></ol></div><a name="wp80971"> </a><h3 class="pHeading2">Packaging the Enterprise Beans</h3><a name="wp81203"> </a><p class="pBody">You will now package the four enterprise beans, RosterEJB, LeagueEJB, PlayerEJB, TeamEJB. RosterEJB, a stateful session bean, will be packaged in RosterJAR. LeagueEJB, PlayerEJB, and TeamEJB are entity beans using container-managed persistence, and will be packaged in TeamJAR.</p><a name="wp81204"> </a><h4 class="pHeading3">Packaging RosterEJB</h4><div class="pSmartList1"><ol type="1" class="pSmartList1"><a name="wp81131"> </a><div class="pSmartList1"><li>Create a new enterprise bean in RosterApp by selecting File<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>New<span style="font-family: Symbol"><img src="images/arrwrite.gif" border="0" alt="Right Arrow"></span>Enterprise Bean.</li></div><a name="wp81132"> </a><div class="pSmartList1"><li>In the EJB JAR screen:</li></div><div class="pSmartList2"><ol type="a" class="pSmartList2"><a name="wp81133"> </a><div class="pSmartList2"><li>Select Create New JAR Module in Application.</li></div><a name="wp81134"> </a><div class="pSmartList2"><li>Enter <code class="cCode">RosterJAR</code> under JAR Name.</li></div><a name="wp81135"> </a><div class="pSmartList2"><li>Click Edit.</li></div>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -