createStatement()和createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY)
一个带参数和一个不带参数有什么区别阿?

解决方案 »

  1.   

    createStatement
    public Statement createStatement(int resultSetType,
                                     int resultSetConcurrency)
                              throws SQLException
    Creates a Statement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the createStatement method above, but it allows the default result set type and concurrency to be overridden. Parameters:
    resultSetType - a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
    resultSetConcurrency - a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE 
    Returns:
    a new Statement object that will generate ResultSet objects with the given type and concurrency 
    Throws: 
    SQLException - if a database access error occurs or the given parameters are not ResultSet constants indicating type and concurrency
      

  2.   

    public Statement createStatement()
                              throws SQLException
    Creates a Statement 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 may be more efficient to use a PreparedStatement object. 
    Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. 
    Returns:
    a new default Statement object
      

  3.   

    不带参数使用默认值:createStatement()
    =createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY)
      

  4.   

    jihanzhong(逍遥):
                      你能帮我解释一下ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE;ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
    这几个参数的意思吗?
      

  5.   

    ResultSet.RTYPE_FORWORD_ONLY:这是缺省值,只可向前滚动; 
    ResultSet.TYPE_SCROLL_INSENSITIVE:双向滚动,但不及时更新,就是如果数据库里的数据修改过,并不在ResultSet中反应出来。 
    ResultSet.TYPE_SCROLL_SENSITIVE:双向滚动,并及时跟踪数据库的更新,以便更改ResultSet中的数据。ResultSet.CONCUR_READ_ONLY:这是缺省值,指定不可以更新 ResultSet 
    ResultSet.CONCUR_UPDATABLE:指定可以更新 ResultSet