Rs.getString("UrlPath")与这个Rs.getString(1)的区别是什么呢

解决方案 »

  1.   

    Rs.getString("UrlPath") 这个是取列名是UrlPath的值,这个不一定是第一列哦
    Rs.getString(1) 这个是取第一列的值。
      

  2.   

    String java.sql.ResultSet.getString(String columnName) throws SQLException
    Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language. Parameters:
    columnName the SQL name of the column
    Returns:
    the column value; if the value is SQL NULL, the value returned is null
    Throws:
    SQLException if a database access error occurs***********************************************************************************************String java.sql.ResultSet.getString(int columnIndex) throws SQLException
    Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language. Parameters:
    columnIndex the first column is 1, the second is 2, ...
    Returns:
    the column value; if the value is SQL NULL, the value returned is null
    Throws:
    SQLException if a database access error occurs
      

  3.   

    第一个是按照列名取第二个是按照表的字段sql语句的显示顺序取.
      

  4.   

    这么说吧,Rs.getString("UrlPath")就是取得列名为UrlPath那列的值,而Rs.getString(1)是取得返回所有列中的第一列的值,两种方式是通用的。
      

  5.   

    Rs.getString("UrlPath")获得制定字段的值,UrlPath是你数据库表中的字段。
    与这个Rs.getString(1),1是在你数据库中第一个字段的值,
    如果你只是显式查看一列而数据库没有的话,你用这个不是方便吗?
      

  6.   

    我一般用 Rs.getString("UrlPath") 这种