当前位置: 技术问答>java相关
rs.getString(变量),这样怎样写???
来源: 互联网 发布时间:2015-11-15
本文导语: rs.getString(变量) 动态查询结果,这样该怎样写, | Statement stmt = con.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ...
rs.getString(变量)
动态查询结果,这样该怎样写,
动态查询结果,这样该怎样写,
|
Statement stmt = con.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
while(rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
String getString(int columnIndex)
Gets the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
String getString(String columnName)
Gets the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
while(rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
String getString(int columnIndex)
Gets the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
String getString(String columnName)
Gets the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
|
String id=new String();
String name=new String();
id="id";
name="name";
while(rs.next()){
System.out.println(rs.getString(id));
System.out.println(rs.getString(name));
}
String name=new String();
id="id";
name="name";
while(rs.next()){
System.out.println(rs.getString(id));
System.out.println(rs.getString(name));
}
|
String filedName="id";
rs.getString(filedName);
rs.getString(filedName);
|
String [] field=存放字段名;
String [] str=null;
while(rs.next())//这里应该用if,如果用while,是否结果集中有多条,则下边一定出错
{
for(int i=0;i
String [] str=null;
while(rs.next())//这里应该用if,如果用while,是否结果集中有多条,则下边一定出错
{
for(int i=0;i