我试图在 jsp 中调用一个返回结果集的方法。喜欢,
在 JSP 中:
OracleResultSet rs = null;
rs = getMyValuesHere();
out.println("rs:"+rs);
// rs is not null.Something like oracle.jdbc.driver.OracleResultSetImpl@1f1e1f
如何从结果集中检索我的值?因为甚至没有进入这个while循环。,
while(rs.next()) {
}
方法是:
<%!
public OracleResultSet getMyValuesHere()
{
OracleConnection connection = null;
OraclePreparedStatement ptmst = null;
OracleResultSet rs = null;
OracleCallableStatement cstmt = null;
StringBuffer sql = new StringBuffer();
//My query goes here
connection = (OracleConnection) TransactionScope.getConnection();
sql.append("SELECT DISTINCT something.... ");
rs = (OracleResultSet)ptmst.executeQuery();
return rs;
}
%>
我尝试将数据打印在getMyValuesHere()
rs = (OracleResultSet)ptmst.executeQuery();
while (rs.next())
{
// rs.getString(1)) -- I was able to print this.
}