我只是试图从服务器(getStat),就是这样看调用存储功能:
create type stat as (type text, location text, number int);
create function getStat() returns setof stat as 'select distinct table1.type, table1.location, table1.number from table1, table2 where table2.finding=10 order by number desc;' language 'sql';
现在这里是JDBC代码:
CallableStatement callable = null;
String storedProc = "{call getStat(?, ?, ?)}";
try {
callable = connection.prepareCall(storedProc);
callable.registerOutParameter(1, java.sql.Types.VARCHAR);
callable.registerOutParameter(2, java.sql.Types.VARCHAR);
callable.registerOutParameter(3, java.sql.Types.INTEGER);
boolean results = callable.execute();
System.out.println(callable.getString(1));
System.out.println(callable.getString(2));
System.out.println(callable.getInt(3));
while(results){
ResultSet rs = callable.getResultSet();
while(rs.next()){
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
System.out.println(rs.getInt(3));
}
//rs.close();
results = callable.getMoreResults();
}
好了,现在的问题:当我调用它,它只是打印出第一行,全散装的,应当printend。 是啊,这是明确的,因为我执行下面的代码:
System.out.println(callable.getString(1));
System.out.println(callable.getString(2));
System.out.println(callable.getInt(3));
但我做同样的while循环......并显示仅此而已。
也许这个问题是显而易见的事情,但我缺少:(
谢谢!