getString(int columnIndex)
参数说明:Connection conn = …… //省略部分代码 String sql = "SELECT username,pwd FROM myTable"; //定义查询SQL语句 Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); while(rs.next()){ System.out.println(rs.getString(1)); //获取数据表中第一列数据值 System.out.println(rs.getString(2)); //获取数据表中第二列数据值 }
getString(String columnLabel))
参数说明:Connection conn = …… //省略部分代码 String sql = "SELECT username,pwd FROM myTable"; Statement st = conn.createStatement(); ResultSet rs = st.executeQuery(sql); while(rs.next()){ System.out.println(rs.getString("username")); //获取username列的列值 System.out.println(rs.getString("pwd")); //获取pwd列的列值 }
本文链接:http://task.lmcjl.com/news/18951.html