<sql-connect>

The <sql-connect> element will open a connection to a database server using the specified connection protocols and user credentials. The contents of this element include the <sql-command> element, which contains the SQL command to execute against the database with which the <sql-connect> element opens a connection. This connection will be closed after the processing of the <sql-connect> element and its contents has completed. In order for this element open a connection the host system upon which the test script is being played must have the proper configuration in place for the connection. For example the ODBC System DSN for a SQL Server database, or the TNS Name for an Oracle database connection. The attributes of this element specify whether or not to save the results of execution of any SQL commands to a log file.

Structure

Contains:
  • <sql-command>
Contained By:
  • <script>
Attributes
Name Description Data Type Default Value Required
dbConnectionName The name of the connection configuration component for the target database; e.g. DSN, TNS Name, etc. String None Yes
dbConnectionType The type of connection to make. This must match the connection configuration component type named in dbConnectionName. Valid values for this attribute include:
  • DB2
  • Informix
  • Interbase
  • MsSQL
  • ODBC (recommended setting for SQL Server connections)
  • Oracle
  • Postgre
  • SQLBase
  • SQLServer
  • Sysbase
String None Yes
dbConnectionUserID The user ID to connect to the database system. String None Yes
dbConnectionPassword The password for the user ID. String None Yes
commandFile The full path and file name, including extensions, of a plain text file containing the SQL command(s) to execute once connected. This attribute is optional and should if used when one or more <sql-command> elements are contained in the <sql-connect> element, will be executed before those commands. String None No
saveQuery This attribute specifies whether or not to log the SQL command executed against the database. This is a Boolean value, with true indicating the query should be saved. This attribute is ignored if saveFile is not present. Boolean False No
saveResult This attribute specifies whether or not to log the result of executing the SQL command(s) contained within the <sql-connect> element or any <sql-command> elements it contains. This is a Boolean value, with true indicating the results should be saved. Note that results are the responses of the database system, not the data returned by a query. This attribute is ignored if saveFile is not present. Boolean False No
saveFile This attribute can contain the full path and file name to which log messages from any SQL commands will be written. If this attribute is not set saveQuery and saveResult are ignored. String False No
ignoreErrors This attribute specifies whether or not any errors generated by the <sql-connection> element’s operations should be ignored. This is a Boolean value, with true indicating errors should be ignored. If not set or set to false (default) any errors resulting from attempting to connect to the database, or in executing a SQL command, will result in a script error being thrown. Any <sql-command> elements contained in the <sql-connect> element can override this setting. Boolean False No
common script attributes This element includes the following common script attributes:
  • timeout
  • sleep
N/A N/A N/A