• 【从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代表一个活动的连接
  • 相关阅读:
    扩展DigitalClock显示日期+时间
    利用Handler定时更新Android UI
    CheckBox在表格中全选、部分选和反选
    jQuery实现表格间隔色
    Android中对话框(dialog)的使用
    The connection to adb is down, and a severe error has occured.
    struts2类型转化
    Android开发之旅:环境搭建及HelloWorld
    C/C++浮点数在内存中的存储方式
    用标签写登录界面
  • 原文地址:https://www.cnblogs.com/kimisme/p/6088280.html
Copyright © 2020-2023  润新知