【从API学英语】-PreparedStatement

原文

An object that represents a precompiled SQL statement. 
A SQL statement is precompiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times. 

Note: The setter methods (setShort, setString, and so on) 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 INTEGER, then the method setInt should be used. 

If arbitrary parameter type conversions are required, the method setObject should be used with a target SQL type. 

In the following example of setting a parameter, con represents an active connection: 

   PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                     SET SALARY = ? WHERE ID = ?");
   pstmt.setBigDecimal(1, 153833.00)
   pstmt.setInt(2, 110592)

翻译

一个对象(它代表一个预编译的sql statement)

一个sql Statement是预编译的,存储在一个PreparedStatement对象。
这个对象可以常常高效的多次执行这个statement。

备注:设置方法(setShort,setString,等等)用来设置IN参数值时必须指定类型(这个类型兼容被定义的输入参数的sql类型)。
例如,如果IN参数有SQL类型INTEGER,那么setInt方法就应该被使用。

如果需要任意参数类型转换,应该使用setObject()方法指定sql类型。

在下面的例子中,设置一个参数,con代表一个活动的连接
原文地址:https://www.cnblogs.com/kimisme/p/6088280.html