class %UnitTest.JDBCSQL
extends %RegisteredObject, %UnitTest.Utility
Extends Utility. Methods to execute sql files against Cache JDBC SQL and return results in a stream.
parameter Password = "SYS";
Specify password for jdbc database connection
parameter Port;
Specify Cache Super Server Port for jdbc database connection
parameter Url = "127.0.0.1";
Specify url for jdbc database connection
parameter Username = "_system";
Specify username for jdbc database connection
classmethod ExecuteSQL(gc As %Net.Remote.Java.JDBCGateway, sql As %String, ByRef sqlhstmt As %Library.ObjectHandle, err As %String = "", rowcount As %Integer = 0)
as %Status
This method executes a SQL statement on the associated JDBC gateway. It will attempt to
guess whether the command is DDL, insert/update/delete or something returning data based on
the first word of the SQL statement.
- gc is the JDBCGateway created when calling $$GetJConnection^%apiGTW(gatewayName)
- sql is the SQL statement to be prepared
- sqlhstmt is passed by reference and is the value returned by the prepare call.
This will be used by future methods (ExecuteSQL)
- err is error message returned by %JDBCGateway
- rowcount is number of rows returned by %JDBCGateway
classmethod PrepareSQL(gc As %Net.Remote.Java.JDBCGateway, sql As %String, ByRef sqlhstmt As %Library.ObjectHandle, ByRef err As %String = "")
as %Status
This method prepares a SQL statement on the associated JDBC gateway
- gc is the JDBCGateway created when calling $$GetJConnection^%apiGTW(gatewayName)
- sql is the SQL statement to be prepared
- sqlhstmt is passed by reference and is the value returned by the prepare call.
This will be used by future methods (ExecuteSQL)
- err is error message returned by %JDBCGateway
classmethod getJDBCGateway(ByRef gcn As %String = "", jdk As %String = "", usn As %String = "_system", pwd As %String = "SYS")
as %Status
Find or create JDBC Gateway Connection
- gcn is Gateway Connection Name to use. If null a name will be created.
- jdk is the kit, for example 16 is 1.6. If null the jdk will be looked up.
- usn is sql username, default is _system
- pwd is sql password, default is SYS
Name = "JDBC" for Unix
classmethod processRStoStream(ByRef sqlhstmt As %Library.ObjectHandle, ByRef output As %Stream, metadata As %Boolean = 0)
as %Status
This method will output the metadata of the passed in hstmt to output if metadata=1.
This method will output the results of the passed in hstmt to output.
classmethod runJDBCSQL(sqlfilename As %String, ByRef gcn As %String = "", verbose As %Boolean = 0)
as %Stream
Connect to SQL Gateway Connection via JDBC and run SQL from sqlfilename in ANY namespace.