📄 preparedstatement.html
字号:
<!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 Apr 27 23:36:23 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Interface PreparedStatement</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> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/PreparedStatement.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../java/sql/Driver.html"><B>PREV CLASS</B></A> <A HREF="../../java/sql/Ref.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> <A HREF="PreparedStatement.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.sql</FONT><BR>Interface PreparedStatement</H2><DL><DT><B>All Superinterfaces:</B> <DD><A HREF="../../java/sql/Statement.html">Statement</A></DD></DL><DL><DT><B>All Known Subinterfaces:</B> <DD><A HREF="../../java/sql/CallableStatement.html">CallableStatement</A></DD></DL><HR><DL><DT>public interface <B>PreparedStatement</B><DT>extends <A HREF="../../java/sql/Statement.html">Statement</A></DL><P>An object that represents a precompiled SQL statement. <P>A SQL statement is precompiled and stored in a <code>PreparedStatement</code> object. This object can then be used to efficiently execute this statement multiple times. <P><B>Note:</B> The setXXX methods for setting IN parameter values must specify types that are compatible with the defined SQL type of the input parameter. For instance, if the IN parameter has SQL type <code>Integer</code>, then the method <code>setInt</code> should be used. <p>If arbitrary parameter type conversions are required, the method <code>setObject</code> should be used with a target SQL type. <br> Example of setting a parameter; <code>con</code> is an active connection <pre><code> PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?"); pstmt.setBigDecimal(1, 153833.00) pstmt.setInt(2, 110592) </code></pre><P><DL><DT><B>See Also: </B><DD><A HREF="../../java/sql/Connection.html#prepareStatement(java.lang.String)"><CODE>Connection.prepareStatement(java.lang.String)</CODE></A>, <A HREF="../../java/sql/ResultSet.html"><CODE><P> Some of the methods in this interface are new in the JDBC 2.0 API.</CODE></A></DL><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> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#addBatch()">addBatch</A></B>()</CODE><BR> Adds a set of parameters to this <code>PreparedStatement</code> object's batch of commands.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#clearParameters()">clearParameters</A></B>()</CODE><BR> Clears the current parameter values immediately.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#execute()">execute</A></B>()</CODE><BR> Executes any kind of SQL statement.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/sql/ResultSet.html">ResultSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#executeQuery()">executeQuery</A></B>()</CODE><BR> Executes the SQL query in this <code>PreparedStatement</code> object and returns the result set generated by the query.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#executeUpdate()">executeUpdate</A></B>()</CODE><BR> Executes the SQL INSERT, UPDATE or DELETE statement in this <code>PreparedStatement</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> <A HREF="../../java/sql/ResultSetMetaData.html">ResultSetMetaData</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#getMetaData()">getMetaData</A></B>()</CODE><BR> Gets the number, types and properties of a <code>ResultSet</code> object's columns.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setArray(int, java.sql.Array)">setArray</A></B>(int i, <A HREF="../../java/sql/Array.html">Array</A> x)</CODE><BR> Sets the designated parameter to the given <code>Array</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setAsciiStream(int, java.io.InputStream, int)">setAsciiStream</A></B>(int parameterIndex, <A HREF="../../java/io/InputStream.html">InputStream</A> x, int length)</CODE><BR> Sets the designated parameter to the given input stream, which will have the specified number of bytes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setBigDecimal(int, java.math.BigDecimal)">setBigDecimal</A></B>(int parameterIndex, <A HREF="../../java/math/BigDecimal.html">BigDecimal</A> x)</CODE><BR> Sets the designated parameter to a <code>java.math.BigDecimal</code> value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setBinaryStream(int, java.io.InputStream, int)">setBinaryStream</A></B>(int parameterIndex, <A HREF="../../java/io/InputStream.html">InputStream</A> x, int length)</CODE><BR> Sets the designated parameter to the given input stream, which will have the specified number of bytes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setBlob(int, java.sql.Blob)">setBlob</A></B>(int i, <A HREF="../../java/sql/Blob.html">Blob</A> x)</CODE><BR> Sets the designated parameter to the given <code>Blob</code> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setBoolean(int, boolean)">setBoolean</A></B>(int parameterIndex, boolean x)</CODE><BR> Sets the designated parameter to a Java <code>boolean</code> value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setByte(int, byte)">setByte</A></B>(int parameterIndex, byte x)</CODE><BR> Sets the designated parameter to a Java <code>byte</code> value.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setBytes(int, byte[])">setBytes</A></B>(int parameterIndex, byte[] x)</CODE><BR> Sets the designated parameter to a Java array of bytes.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setCharacterStream(int, java.io.Reader, int)">setCharacterStream</A></B>(int parameterIndex, <A HREF="../../java/io/Reader.html">Reader</A> reader, int length)</CODE><BR> Sets the designated parameter to the given <code>Reader</code> object, which is the given number of characters long.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/sql/PreparedStatement.html#setClob(int, java.sql.Clob)">setClob</A></B>(int i,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -