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

📄 code4.html

📁 jdbc书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<H3>Entity Context Methods</H3>

An entity Bean has an associated <CODE>EntityContext</CODE>
instance that gives the Bean access to container-managed runtime
information such as the transaction context. 

</FONT>

<PRE>
  public void setEntityContext(
                javax.ejb.EntityContext ctx)
                throws RemoteException {
    this.ctx = ctx;
  }

  public void unsetEntityContext() 
                throws RemoteException{
    ctx = null;
  }
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<A NAME="load"></A>
<H3>Load Method</H3>

The Bean's <CODE>ejbLoad</CODE> method is called by the
container to load data from the underlying storage medium. 
This would be necessary
when <CODE>BidderBean</CODE> or <CODE>SellerBean</CODE>
need to check a user's ID or password against the stored values.

<BLOCKQUOTE>
<HR>
<STRONG>Note:</STRONG>
Not all Bean objects are live at any one time. The Enterprise
JavaBeans<FONT SIZE="-2"><SUP>TM</SUP></FONT> server might have a configurable number of
Beans that it keeps in memory.
<HR>
</BLOCKQUOTE>

<P>
This method is not implemented because the Enterprise JavaBeans 
container seamlessly loads the data from the underlying storage
medium for you.

</FONT>

<PRE>
  public void ejbLoad() throws RemoteException {}
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<A NAME="store"></A>
<H3>Store Method</H3>

The Bean's <CODE>ejbStore</CODE> method is called by the container
to save user data.  This method is not implemented
because the Enterprise JavaBeans container seamlessly stores
the data to the underlying storage medium for you.

</FONT>

<PRE>
  public void ejbStore() throws RemoteException {}
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<A NAME="pool"></A>
<H3>Connection Pooling</H3>

Loading data from and storing data to a database can take a lot
time and reduce an application's overall performance. To reduce 
database connection time, the BEA Weblogic server uses a JDBC<FONT SIZE="-2"><SUP>TM</SUP></FONT> 
connection pool to cache database connections so connections
are always available when the appalication needs them.

<P>
However, you are not limited to the default JDBC connection pool.
You can override the Bean-managed connection pooling behaviour
and substitute your own.  
<A HREF="perfTech.html">Chapter 8: Performance Techniques</A> 
explains how.

<A NAME="deployment"></A>
<H3>Deployment Descriptor</H3>

The remaining configuration for a container-managed persistent Beans
occurs at deployment time. The following is the text-based
Deployment Descriptor
used in a BEA Weblogic Enterprise JavaBeans server.

<H4>Text Deployment Descriptor</H4>

</FONT>

<PRE>
  (environmentProperties

    (persistentStoreProperties
      persistentStoreType          jdbc

      (jdbc
        tableName                  registration
        dbIsShared                 false
        poolName                   ejbPool
        (attributeMap
          creditcard               creditcard
          emailaddress             emailaddress
          balance                  balance
          password                 password
          theuser                  theuser
        ); end attributeMap
      ); end jdbc
    ); end persistentStoreProperties
  ); end environmentProperties

</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

The deployment descriptor indicates that storage is a database 
whose connection is held in a JDBC<FONT SIZE="-2"><SUP>TM</SUP></FONT> connection pool
called <CODE>ejbPool</CODE>. The <CODE>attributeMap</CODE> contains
the Enterprise Bean variable on the left and the associated database field on 
the right. 

<H4>XML Deployment Descriptor</H4>

In Enterprise JavaBeans 1.1, the deployment descriptor uses 
<CODE>XML</CODE>. The equivalent configuration in <CODE>XML</CODE>
is as follows:

</FONT>

<PRE>
&lt;persistence-type&gt;Container&lt;/persistence-type&gt;
&lt;cmp-field&gt;&lt;field-name&gt;creditcard
    &lt;/field-name&gt;&lt;/cmp-field&gt;
&lt;cmp-field&gt;&lt;field-name&gt;emailaddress
    &lt;/field-name&gt;&lt;/cmp-field&gt;
&lt;cmp-field&gt;&lt;field-name&gt;balance
    &lt;/field-name&gt;&lt;/cmp-field&gt;
&lt;cmp-field&gt;&lt;field-name&gt;password
    &lt;/field-name&gt;&lt;/cmp-field&gt;
&lt;cmp-field&gt;&lt;field-name&gt;theuser
    &lt;/field-name&gt;&lt;/cmp-field&gt;
&lt;resource-ref&gt;
&lt;res-ref-name&gt;registration&lt;/res-ref-name&gt;
&lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
&lt;res-auth&gt;Container&lt;/res-auth&gt;
&lt;/resource-ref&gt;
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

The container managed-fields here map directly to their counterpart
names in the database table. The container resource authorization 
(<CODE>res-auth</CODE>) means the container handles the database login 
for the <CODE>REGISTRATION</CODE> table.

<P ALIGN="RIGHT">
<FONT SIZE="-1">[<A HREF="#top">TOP</A>]</FONT>

</FONT>
</TD>
</TR>
</TABLE>




<!-- ================ -->
<!-- End Main Content -->
<!-- ================ -->

</TD>
</TR>
</TABLE>

<!-- Copyright Insert -->

<BR CLEAR="ALL">

<FORM ACTION="/cgi-bin/search.cgi" METHOD="POST">
<TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="5">   
  <TR>
    <TD VALIGN="TOP">
	
    <P ALIGN=CENTER>
    <FONT SIZE="-1" COLOR="#999999" FACE="Verdana, Arial, Helvetica, sans-serif">
    [ This page was updated: <!-- new date --> 13-Oct-99 ]</font></P>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>
  
  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/products/">Products &amp; APIs</A> | 
    <A HREF="/developer/index.html">Developer Connection</A> | 
    <A HREF="/developer/infodocs/index.shtml">Docs &amp; Training</A> | 
    <A HREF="/developer/support/index.html">Online Support</A><BR>
    <A HREF="/developer/community/index.html">Community Discussion</A> |
    <A HREF="http://java.sun.com/industry/">Industry News</A> | 
    <A HREF="http://java.sun.com/solutions">Solutions Marketplace</A> | 
    <A HREF="http://java.sun.com/casestudies">Case Studies</A>
    </FONT>
    </CENTER>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>

  <TR>
    <TD ALIGN="CENTER">
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/docs/glossary.html">Glossary</A> - 
    <A HREF="http://java.sun.com/applets/">Applets</A> - 
    <A HREF="http://java.sun.com/docs/books/tutorial/">Tutorial</A> - 
    <A HREF="http://java.sun.com/jobs/">Employment</A> - 
    <A HREF="http://java.sun.com/nav/business/">Business &amp; Licensing</A> - 
    <A HREF="http://java.sun.com/javastore/">Java Store</A> -
    <A HREF="http://java.sun.com/casestudies/">Java in the Real World</A>
    </FONT>
    </TD>
  </TR>

  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <a href="/siteinfo/faq.html">FAQ</a> |
    <a href="/feedback/index.html">Feedback</a> | 
    <a href="http://www.dynamicdiagrams.net/mapa/cgi-bin/help.tcl?db=javasoft&dest=http://java.sun.com/">Map</a> | 
    <A HREF="http://java.sun.com/a-z/index.html">A-Z Index</A>
    </FONT>
    </CENTER>

    </TD>
  </TR>
  
  <TR>
    <TD>

    <TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="0">
      <TR>
        <TD WIDTH="50%">
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        For more information on Java technology<BR>
        and other software from Sun Microsystems, call:<BR>
        </FONT>
        <FONT SIZE="-1" FACE="Verdana, Arial, Helvetica, sans-serif">
        (800) 786-7638<BR></FONT>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Outside the U.S. and Canada, dial your country's 
        <A HREF="http://www.att.com/business_traveler/attdirecttollfree/">AT&amp;T&nbsp;Direct&nbsp;Access&nbsp;Number</A> first.<BR>
        </FONT>
        </TD>

        <TD ALIGN="RIGHT" WIDTH="50%">
        <A HREF="http://www.sun.com"><IMG SRC="/images/lgsun.gif" width="64" height="30" border="0" ALT="Sun Microsystems, Inc."></A><BR>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Copyright &copy; 1995-99
        <A HREF="http://www.sun.com">Sun Microsystems, Inc.</A><BR>
        All Rights Reserved. 
        <a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>. 
        <A HREF="http://www.sun.com/privacy/">Privacy&nbsp;Policy</A>.
        </FONT>
        </TD>
      </TR>
    </TABLE>
	
    </TD>
  </TR> 
</TABLE>
</FORM>

<!-- End Copyright Insert -->


</BODY>
</HTML>

⌨️ 快捷键说明

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