Starting JDBC Driver Manager Trace in a PowerBuilder application

To start JDBC Driver Manager Trace in a PowerBuilder application, you must specify the TraceFile DBParm parameter in the appropriate script. For example, you might include it in the script that opens the application.

You can specify the TraceFile parameter in a PowerBuilder script by:

For more about using Transaction objects to communicate with a database in a PowerBuilder application, see Application Techniques.

About the TraceFile DBParm parameter

TraceFile controls the operation of JDBC Driver Manager Trace for any JDBC-compatible driver you are using in PowerBuilder.

Copying TraceFile syntax from the Preview tab

The easiest way to start JDBC Driver Manager Trace in a PowerBuilder application script is to copy the PowerScript TraceFile DBParm syntax from the Preview tab in the Database Profile Setup - JDBC dialog box into your script, modifying the default Transaction object name (SQLCA) if necessary.

As you complete the Database Profile Setup dialog box in the development environment, PowerBuilder generates the correct connection syntax on the Preview tab. Therefore, copying the syntax directly from the Preview tab into your script ensures that it is accurate.

StepsTo copy TraceFile syntax from the Preview tab into your script:

  1. On the Options tab in the Database Profile Setup - JDBC dialog box for your connection, select the Trace JDBC Calls check box and (optionally) specify a log file in the Trace File box to start JDBC Driver Manager Trace.

    For instructions, see “Stopping JDBC Driver Manager Trace in the development environment”.

  2. Click Apply to save your changes to the Options tab without closing the dialog box.

  3. Click the Preview tab.

    The correct PowerScript syntax for JDBC Driver Manager Trace and other selected options displays in the Database Connection Syntax box.

    The following example shows the PowerScript syntax that starts JDBC Driver Manager Trace and sends output to the file C:\TEMP\JDBC.LOG.

    // Profile Employee
    SQLCA.DBMS = "TRACE JDBC"
    SQLCA.DBParm = "Driver='com.sybase.jdbc3.jdbc.SybDriver',
    URL='jdbc:sybase:Tds:199.93.178.151:5007/tsdata',
    TraceFile='c:\temp\jdbc.log'"
    
  4. Select the DBParm line and any other syntax you want to copy to your script and click Copy.

    PowerBuilder copies the selected text to the clipboard.

  5. Paste the selected text from the Preview tab into your script, modifying the default Transaction object name (SQLCA) if necessary.

Coding PowerScript to set a value for the DBParm property

Another way to start JDBC Driver Manager Trace in a PowerBuilder application script is to include the TraceFile parameter as a value for the DBParm property of the Transaction object.

StepsTo start JDBC Driver Manager Trace by setting the DBParm property:

  1. In your application script, include the TraceFile parameter to start the trace and specify a nondefault trace file.

    For example, this statement starts JDBC Driver Manager Trace in your application and sends output to a file named MYTRACE.LOG. (This example assumes you are using the default Transaction object SQLCA, but you can also define your own Transaction object.)

    SQLCA.DBParm = "Driver='com.sybase.jdbc3.jdbc.SybDriver',
    URL='jdbc:sybase:Tds:199.93.178.151:5007/tsdata',
    TraceFile='c:\MYTRACE.LOG'"
    

Reading the DBParm value from an external text file

As an alternative to setting the DBParm property in your PowerBuilder application script, you can use the PowerScript ProfileString function to read DBParm values from a specified section of an external text file, such as an application-specific initialization file.

This assumes that the DBParm value read from your initialization file includes the TraceFile parameter to start JDBC Driver Manager Trace, as shown in the preceding example.

StepsTo start JDBC Driver Manager Trace by reading DBParm values from an external text file:

  1. Use the following PowerScript syntax to specify the ProfileString function with the DBParm property:

    SQLCA.dbParm = ProfileString(file, section, variable,
       default_value)
    

    For example, the following statement in a PowerBuilder script reads the DBParm values from the [Database] section of the APP.INI file:

    SQLCA.dbParm =
    
       ProfileString("APP.INI","Database","DBParm","")