GetResultSet

Description

Returns the result set in a cursor. This method is for use in JSP targets only.

Applies to

PSCursorClass objects

Syntax

cursorobject.GetResultSet ( )

Argument

Description

cursorobject

A variable that contains a reference to an instance of PSCursorClass

Returns

java.sql.ResultSet

Examples

Example 1

This example gets the java.sql.ResultSet from the cursor class through the GetResultSet method. The result set is manipulated using common java.sql.ResultSet methods:

<% 
   try { 
    PSConnectionClass dbconn = new
         PSConnectionClass(pageContext,
         "com.sybase.jdbc2.jdbc.SybDriver",
         "jdbc:sybase:Tds:localhost:2638",
         "dba","sql", false); 
    PSCommandClass sqlcmd =
         dbconn.CreateCommand("select * from product");
    PSCursorClass mycursor = sqlcmd.Execute();
    java.sql.ResultSet rs = mycursor.GetResultSet();
    java.sql.ResultSetMetaData md = rs.getMetaData();
    psDocument.Write("<TABLE border=1>");
    psDocument.Write("<TR>");
    for (int col=1; col<= md.getColumnCount(); col++){
          psDocument.Write("<TD><B>"+
          md.getColumnName(col)+"</B></TD>");
         }
    psDocument.Write("</TR>");
    while(rs.next()) {	
         psDocument.Write("<TR>"); 
         for(int i=1; i<= md.getColumnCount(); i++) {
             psDocument.Write("<TD>"+rs.getString(i) +
                "</TD>"); 
             }
         	psDocument.Write("</TR>"); 
         }
    psDocument.Write("</TABLE>"); 
    rs.close(); 
    } 
   catch(Exception e) {
    e.printStackTrace(); 
    }
%>

Example 2

The following example uses the getResultSet method of the com.sybase.CORBA.jdbc11.SQL class to convert data from a tabular result set obtained by the “n_resultset” component running on EAServer. The connection to the database is handled by the component.

<%@ page import="com.sybase.CORBA.jdbc11.SQL" %>
...
<% 
TabularResults.ResultSet trs=       n_resultset.of_getresultset();
java.sql.ResultSet rs = SQL.getResultSet(trs );while (rs.next())
  {psDocument.Write(Integer.toString(rs.getInt
      ("dept_id")));
  psDocument.Write("&nbsp&nbsp");
  psDocument.Write(rs.getString("dept_name"));
  psDocument.Write("&nbsp&nbsp");
  psDocument.WriteLn(Integer.toString(rs.getInt(
    "dept_head_id")));
} 
%>

See also

GetResultSetMetaData