Chapter 12 Calling EAServer Component Methods from PowerDynamo
When a Dynamo script calls an EAServer component through Java, results are returned as Tabular ResultSets. Tabular ResultSets have different properties and methods than the Dynamo query object. Dynamo includes a script called javaqry.ssc that is installed in the system/utils folder of the Dynamo web site. This script implements a class called JavaQuery which takes as a parameter a TabularResults Set object sent by EAServer and returns a class that has methods mimicking those of a Dynamo query object.
Scripts that call an EAServer component through Java and do not make use of the JavaQuery class look something like this:
comp = java.CreateComponent( "SVU/SVUEnrollment" ); prequery = comp.getMajors(); query = java.CallStaticMethod( "com.sybase.CORBA.jdbc11.SQL","getResultSet",prequery ); received = query.next(); metadata = query.getMetaData(); columns = metadata.getColumnCount(); document.writeln( "There are " + columns + " columns" ); while( received ) { fields = query.Fields; for( j = 0; j < columns; j++ ) { value = query.getString( j ) document.writeln( value ); } received = query.next(); }
Using the JavaQuery class, you could use:
import ~/system/utils/javaqry.ssc; comp = java.CreateComponent( "SVU/SVUEnrollment" ); // returns Tabular ResultSet object query = comp.getMajors(); // wrap up the Tabular ResultSet to mimic a Dynamo query //object dynQuery = new JavaQuery( query ); columns = dynQuery.GetColumnCount(); document.writeln( "There are " + columns + " columns" ); while( dynQuery.MoveNext() ) { for( j = 0; j <= columns; j++ ) { value = dynQuery.GetValue(j); document.writeln( value ); } }
Copyright © 2001 Sybase, Inc. All rights reserved. |