datasource.html

来自「SUN公司官方J2EE中文帮助文档 应该不错 有兴趣的下来看看 html格式的」· HTML 代码 · 共 311 行

HTML
311
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc on Thu Jan 17 03:51:39 PST 2002 -->
<TITLE>
Java 2 Platform EE v1.3: Interface  DataSource
</TITLE>
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
</HEAD>
<BODY BGCOLOR="white">

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_top"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../javax/sql/ConnectionPoolDataSource.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/sql/PooledConnection.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="DataSource.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.sql</FONT>
<BR>
Interface  DataSource</H2>
<HR>
<DL>
<DT>public interface <B>DataSource</B></DL>

<P>
<p>A DataSource object is a factory for Connection objects.  An
 object that implements the DataSource interface will typically be
 registered with a JNDI service provider.  A JDBC driver that is 
 accessed via the DataSource API does not automatically register 
 itself with the DriverManager.
<P>
<HR>

<P>
<!-- ======== INNER CLASS SUMMARY ======== -->


<!-- =========== FIELD SUMMARY =========== -->


<!-- ======== CONSTRUCTOR SUMMARY ======== -->


<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.sql.Connection</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#getConnection()">getConnection</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempt to establish a database connection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.sql.Connection</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#getConnection(java.lang.String, java.lang.String)">getConnection</A></B>(java.lang.String&nbsp;username,
              java.lang.String&nbsp;password)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempt to establish a database connection.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#getLoginTimeout()">getLoginTimeout</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gets the maximum time in seconds that this data source can wait
 while attempting to connect to a database.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;java.io.PrintWriter</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#getLogWriter()">getLogWriter</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the log writer for this data source.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#setLoginTimeout(int)">setLoginTimeout</A></B>(int&nbsp;seconds)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the maximum time in seconds that this data source will wait
 while attempting to connect to a database.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../javax/sql/DataSource.html#setLogWriter(java.io.PrintWriter)">setLogWriter</A></B>(java.io.PrintWriter&nbsp;out)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set the log writer for this data source.</TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ============ FIELD DETAIL =========== -->


<!-- ========= CONSTRUCTOR DETAIL ======== -->


<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>

<A NAME="getConnection()"><!-- --></A><H3>
getConnection</H3>
<PRE>
public java.sql.Connection <B>getConnection</B>()
                                  throws java.sql.SQLException</PRE>
<DL>
<DD><p>Attempt to establish a database connection.<DD><DL>
<DT><B>Returns:</B><DD>a Connection to the database<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database-access error occurs.</DL>
</DD>
</DL>
<HR>

<A NAME="getConnection(java.lang.String, java.lang.String)"><!-- --></A><H3>
getConnection</H3>
<PRE>
public java.sql.Connection <B>getConnection</B>(java.lang.String&nbsp;username,
                                         java.lang.String&nbsp;password)
                                  throws java.sql.SQLException</PRE>
<DL>
<DD><p>Attempt to establish a database connection.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>user</CODE> - the database user on whose behalf the Connection is 
  being made<DD><CODE>password</CODE> - the user's password<DT><B>Returns:</B><DD>a Connection to the database<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database-access error occurs.</DL>
</DD>
</DL>
<HR>

<A NAME="getLogWriter()"><!-- --></A><H3>
getLogWriter</H3>
<PRE>
public java.io.PrintWriter <B>getLogWriter</B>()
                                 throws java.sql.SQLException</PRE>
<DL>
<DD><p>Get the log writer for this data source.  

 <p>The log writer is a character output stream to which all logging
 and tracing messages for this data source object instance will be
 printed.  This includes messages printed by the methods of this
 object, messages printed by methods of other objects manufactured
 by this object, and so on.  Messages printed to a data source
 specific log writer are not printed to the log writer associated
 with the java.sql.Drivermanager class.  When a DataSource object is
 created the log writer is initially null, in other words, logging
 is disabled.<DD><DL>
<DT><B>Returns:</B><DD>the log writer for this data source, null if disabled<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database-access error occurs.</DL>
</DD>
</DL>
<HR>

<A NAME="setLogWriter(java.io.PrintWriter)"><!-- --></A><H3>
setLogWriter</H3>
<PRE>
public void <B>setLogWriter</B>(java.io.PrintWriter&nbsp;out)
                  throws java.sql.SQLException</PRE>
<DL>
<DD><p>Set the log writer for this data source.

 <p>The log writer is a character output stream to which all logging
 and tracing messages for this data source object instance will be
 printed.  This includes messages printed by the methods of this
 object, messages printed by methods of other objects manufactured
 by this object, and so on.  Messages printed to a data source
 specific log writer are not printed to the log writer associated
 with the java.sql.Drivermanager class. When a DataSource object is
 created the log writer is initially null, in other words, logging
 is disabled.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>out</CODE> - the new log writer; to disable, set to null<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database-access error occurs.</DL>
</DD>
</DL>
<HR>

<A NAME="setLoginTimeout(int)"><!-- --></A><H3>
setLoginTimeout</H3>
<PRE>
public void <B>setLoginTimeout</B>(int&nbsp;seconds)
                     throws java.sql.SQLException</PRE>
<DL>
<DD><p>Sets the maximum time in seconds that this data source will wait
 while attempting to connect to a database.  A value of zero
 specifies that the timeout is the default system timeout 
 if there is one; otherwise it specifies that there is no timeout.
 When a DataSource object is created the login timeout is
 initially zero.<DD><DL>
<DT><B>Parameters:</B><DD><CODE>seconds</CODE> - the data source login time limit<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database access error occurs.</DL>
</DD>
</DL>
<HR>

<A NAME="getLoginTimeout()"><!-- --></A><H3>
getLoginTimeout</H3>
<PRE>
public int <B>getLoginTimeout</B>()
                    throws java.sql.SQLException</PRE>
<DL>
<DD>Gets the maximum time in seconds that this data source can wait
 while attempting to connect to a database.  A value of zero
 means that the timeout is the default system timeout 
 if there is one; otherwise it means that there is no timeout.
 When a DataSource object is created the login timeout is
 initially zero.<DD><DL>
<DT><B>Returns:</B><DD>the data source login time limit<DT><B>Throws:</B><DD><CODE>java.sql.SQLException</CODE> - if a database access error occurs.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>

<!-- ========== START OF NAVBAR ========== -->
<A NAME="navbar_bottom"><!-- --></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../javax/sql/ConnectionPoolDataSource.html"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../javax/sql/PooledConnection.html"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="DataSource.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY: &nbsp;INNER&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: &nbsp;FIELD&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<!-- =========== END OF NAVBAR =========== -->

<HR>

</BODY>
</HTML>

⌨️ 快捷键说明

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