超级急:cybase的TabularResults.ResultSet

iamyy2002 05-04-15

在CORBA中传递ResultSet,重新得到的ResultSet没了数据,为什么?



// 在此输入java代码

import java.sql.ResultSet;
import java.sql.Connection;

public class Sample {

public static void main(String[] args) {

Connection con = null;
try{

Class.forName(
"org.postgresql.Driver");

con = java.sql.DriverManager.getConnection(
"jdbc:postgresql://localhost/mydb","postgres","password");
java.sql.Statement stm = con.createStatement();
String sql =
"select \"userID\",\"name\" from logindb;";

ResultSet rs = stm.executeQuery(sql);

while(rs.next()){
int userID = rs.getInt(
"userID");
String name = rs.getString(
"name");
System.out.println(
"userID="+userID+" name="+name);
}

TabularResults.ResultSet trrs = com.sybase.CORBA.jdbc11.IDL.getResultSet(rs);

java.sql.ResultSet resultset = com.sybase.CORBA.jdbc11.SQL.getResultSet(trrs);

while(resultset.next()){
int userID = resultset.getInt(
"userID");
String name = resultset.getString(
"name");
System.out.println(
"userID="+userID+" name="+name);
}
System.out.println(
"over");

}catch(Exception e){
e.printStackTrace();
}finally {
try {
con.close();
}catch (java.sql.SQLException sqle) {
System.out.println(
"close connection error: " + sqle.toString());
}
}



}
}

iamyy2002
2005-04-15 12:51

对不起,预览怎么也发了,请删掉一个

iamyy2002
2005-04-15 22:17

我以为ResultSet转换过程中游标会自动复原,原来不是。
低级错误。