connection.html

来自「API資料大全」· HTML 代码 · 共 929 行 · 第 1/3 页

HTML
929
字号
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a <code>PreparedStatement</code> object that will generate <code>ResultSet</code> objects with the given type and concurrency.</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="../../java/sql/Connection.html#rollback()">rollback</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Drops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.</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="../../java/sql/Connection.html#setAutoCommit(boolean)">setAutoCommit</A></B>(boolean&nbsp;autoCommit)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets this connection's auto-commit mode.</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="../../java/sql/Connection.html#setCatalog(java.lang.String)">setCatalog</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;catalog)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets a catalog name in order to select 	 a subspace of this Connection's database in which to work.</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="../../java/sql/Connection.html#setReadOnly(boolean)">setReadOnly</A></B>(boolean&nbsp;readOnly)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Puts this connection in read-only mode as a hint to enable  database optimizations.</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="../../java/sql/Connection.html#setTransactionIsolation(int)">setTransactionIsolation</A></B>(int&nbsp;level)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Attempts to change the transaction isolation level to the one given.</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="../../java/sql/Connection.html#setTypeMap(java.util.Map)">setTypeMap</A></B>(<A HREF="../../java/util/Map.html">Map</A>&nbsp;map)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Installs the given type map as the type map for this connection.</TD></TR></TABLE>&nbsp;<P><!-- ============ FIELD DETAIL =========== --><A NAME="field_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Field Detail</B></FONT></TD></TR></TABLE><A NAME="TRANSACTION_NONE"><!-- --></A><H3>TRANSACTION_NONE</H3><PRE>public static final int <B>TRANSACTION_NONE</B></PRE><DL><DD>Indicates that transactions are not supported.</DL><HR><A NAME="TRANSACTION_READ_UNCOMMITTED"><!-- --></A><H3>TRANSACTION_READ_UNCOMMITTED</H3><PRE>public static final int <B>TRANSACTION_READ_UNCOMMITTED</B></PRE><DL><DD>Dirty reads, non-repeatable reads and phantom reads can occur. This level allows a row changed by one transaction to be read by another transaction before any changes in that row have been committed (a "dirty read").  If any of the changes are rolled back,  the second transaction will have retrieved an invalid row.</DL><HR><A NAME="TRANSACTION_READ_COMMITTED"><!-- --></A><H3>TRANSACTION_READ_COMMITTED</H3><PRE>public static final int <B>TRANSACTION_READ_COMMITTED</B></PRE><DL><DD>Dirty reads are prevented; non-repeatable reads and phantom reads can occur.  This level only prohibits a transaction from reading a row with uncommitted changes in it.</DL><HR><A NAME="TRANSACTION_REPEATABLE_READ"><!-- --></A><H3>TRANSACTION_REPEATABLE_READ</H3><PRE>public static final int <B>TRANSACTION_REPEATABLE_READ</B></PRE><DL><DD>Dirty reads and non-repeatable reads are prevented; phantom reads can occur.  This level prohibits a transaction from reading a row with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the first transaction rereads the row, getting different values the second time (a "non-repeatable read").</DL><HR><A NAME="TRANSACTION_SERIALIZABLE"><!-- --></A><H3>TRANSACTION_SERIALIZABLE</H3><PRE>public static final int <B>TRANSACTION_SERIALIZABLE</B></PRE><DL><DD>Dirty reads, non-repeatable reads and phantom reads are prevented. This level includes the prohibitions in TRANSACTION_REPEATABLE_READ and further prohibits the  situation where one transaction reads all rows that satisfy a WHERE condition, a second transaction inserts a row that satisfies that WHERE condition, and the first transaction rereads for the same condition, retrieving the additional "phantom" row in the second read.</DL><!-- ========= 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="createStatement()"><!-- --></A><H3>createStatement</H3><PRE>public <A HREF="../../java/sql/Statement.html">Statement</A> <B>createStatement</B>()                          throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Creates a <code>Statement</code> object for sending SQL statements to the database. SQL statements without parameters are normally executed using Statement objects. If the same SQL statement  is executed many times, it is more efficient to use a  <code>PreparedStatement</code> object.<P> Result sets created using the returned <code>Statement</code> object will by default have forward-only type and read-only concurrency.<DD><DL><DT><B>Returns:</B><DD>a new Statement object<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs</DL></DD></DL><HR><A NAME="prepareStatement(java.lang.String)"><!-- --></A><H3>prepareStatement</H3><PRE>public <A HREF="../../java/sql/PreparedStatement.html">PreparedStatement</A> <B>prepareStatement</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;sql)                                   throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Creates a <code>PreparedStatement</code> object for sending parameterized SQL statements to the database.  A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times. <P><B>Note:</B> This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method <code>prepareStatement</code> will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the <code>PreparedStatement</code> is executed.  This has no direct effect on users; however, it does affect which method throws certain SQLExceptions. Result sets created using the returned PreparedStatement will have forward-only type and read-only concurrency, by default.<DD><DL><DT><B>Parameters:</B><DD><CODE>sql</CODE> - a SQL statement that may contain one or more '?' IN parameter placeholders<DT><B>Returns:</B><DD>a new PreparedStatement object containing the pre-compiled statement<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs</DL></DD></DL><HR><A NAME="prepareCall(java.lang.String)"><!-- --></A><H3>prepareCall</H3><PRE>public <A HREF="../../java/sql/CallableStatement.html">CallableStatement</A> <B>prepareCall</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;sql)                              throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Creates a <code>CallableStatement</code> object for calling database stored procedures. The <code>CallableStatement</code> object provides methods for setting up its IN and OUT parameters, and methods for executing the call to a stored procedure. <P><B>Note:</B> This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the method <code>prepareCall</code> is done; others may wait until the <code>CallableStatement</code> object is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions. Result sets created using the returned CallableStatement will have forward-only type and read-only concurrency, by default.<DD><DL><DT><B>Parameters:</B><DD><CODE>sql</CODE> - a SQL statement that may contain one or more '?' parameter placeholders. Typically this  statement is a JDBC function call escape string.<DT><B>Returns:</B><DD>a new CallableStatement object containing the pre-compiled SQL statement<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs</DL></DD></DL><HR><A NAME="nativeSQL(java.lang.String)"><!-- --></A><H3>nativeSQL</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>nativeSQL</B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;sql)                 throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Converts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC sql grammar into its system's native SQL grammar prior to sending it; this method returns the native form of the statement that the driver would have sent.<DD><DL><DT><B>Parameters:</B><DD><CODE>sql</CODE> - a SQL statement that may contain one or more '?' parameter placeholders<DT><B>Returns:</B><DD>the native form of this statement<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs</DL></DD></DL><HR><A NAME="setAutoCommit(boolean)"><!-- --></A><H3>setAutoCommit</H3><PRE>public void <B>setAutoCommit</B>(boolean&nbsp;autoCommit)                   throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Sets this connection's auto-commit mode. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions.  Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method <code>commit</code> or the method <code>rollback</code>. By default, new connections are in auto-commit mode. The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases the commit occurs when all results and output parameter values have been retrieved.<DD><DL><DT><B>Parameters:</B><DD><CODE>autoCommit</CODE> - true enables auto-commit; false disables auto-commit.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs</DL></DD></DL><HR><A NAME="getAutoCommit()"><!-- --></A><H3>getAutoCommit</H3><PRE>public boolean <B>getAutoCommit</B>()                      throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Gets the current auto-commit state.<DD><DL><DT><B>Returns:</B><DD>the current state of auto-commit mode<DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs<DT><B>See Also: </B><DD><A HREF="../../java/sql/Connection.html#setAutoCommit(boolean)"><CODE>setAutoCommit(boolean)</CODE></A></DL></DD></DL><HR><A NAME="commit()"><!-- --></A><H3>commit</H3><PRE>public void <B>commit</B>()            throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should be used only when auto-commit mode has been disabled.<DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/sql/SQLException.html">SQLException</A></CODE> - if a database access error occurs<DT><B>See Also: </B><DD><A HREF="../../java/sql/Connection.html#setAutoCommit(boolean)"><CODE>setAutoCommit(boolean)</CODE></A></DL></DD></DL><HR><A NAME="rollback()"><!-- --></A><H3>rollback</H3><PRE>public void <B>rollback</B>()              throws <A HREF="../../java/sql/SQLException.html">SQLException</A></PRE><DL><DD>Drops all changes made since the previous commit/rollback and releases any database locks currently held by this Connection. This method should be used only when auto-

⌨️ 快捷键说明

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