ResultSet的getInt(),getString()方法

ResultSet的getInt(),getString()方法

原文:https://www.cnblogs.com/TTTTT/p/5920655.html

 数据库tt的examstudent数据表如下:

在MySQL中执行查询语句如下:

ResultSet rs = null;

String sql="SELECT flow_id,Type,id_card,exam_card,student_name,location,grade FROM examstudent";

rs = st.executeQuery(sql);

rs:数据集。
rs.getInt(int index);
rs.getInt(String columName);
你可以通过索引或者列名来获得查询结果集中的某一列的值。
例如:while(rs.next)
{
  rs.getInt(1)//等价于rs.getInt("flowid");
  rs.getString(5)//等价于rs.getInt("student_name");
}

猜你喜欢

转载自blog.csdn.net/dingd1234/article/details/81363257