Skip to main content
Skip table of contents

Use the Sample Code to Test the Data Access API

Use the supplied sample code to test the API and verify that you have the JDK and Apache Ant set up correctly.

  1. Make sure SuperSTAR is running, and that the sample Retail Banking database is available on your system.
  2. Open a command prompt and navigate to the Data Access API samples directory.
  3. Run Ant to compile the sample code, by typing:

    CODE
    ant


    This step is not strictly necessary to run the sample code, because there is already a pre-compiled .jar file supplied in the samples directory.

    However, this is a good way to check that Ant is installed and configured correctly on your system. If Ant is configured correctly it will use the settings in build.xml to recompile the sample code and replace the supplied version of dataAccessAPISamples.jar.

  4. Run runSamples.bat. This batch file executes the sample code SimpleTxdQuery, which uses the TXD file provided in the samples directory (txd01.txd) to submit a query to the database and return the output in CSV format.

If you encounter any issues, check the Troubleshooting section below. Once you have confirmed that the sample code is working, you might want to try the following additional tests:

Additional Tests

Use Your Own TXD File

  1. Go to SuperCROSS and generate your own TXD file.
  2. Open runSamples.bat in a text editor.
  3. Locate the line that executes the sample code:

    CODE
    java -Djava.endorsed.dirs="%ENDORSED_DIR%" -DdataAccessAPI.data="%DATA_DIR%" au.com.str.samples.query.SimpleTxdQuery -tn txd01.txd
  4. Change the final parameter (-tn) to point to your TXD file. For example:

    CODE
    java -Djava.endorsed.dirs="%ENDORSED_DIR%" -DdataAccessAPI.data="%DATA_DIR%" au.com.str.samples.query.SimpleTxdQuery -tn MyTXDFile.txd
  5. Run the sample code again and check the output.

Run the Other Samples

  1. Open runSamples.bat in a text editor.
  2. Locate the line that executes the sample code:

    CODE
    java -Djava.endorsed.dirs="%ENDORSED_DIR%" -DdataAccessAPI.data="%DATA_DIR%" au.com.str.samples.query.SimpleTxdQuery -tn txd01.txd
  3. Change this to execute one of the other code samples by replacing au.com.str.samples.query.SimpleTxdQuery with the path to one of the other samples. For example:

    CODE
    java -Djava.endorsed.dirs="%ENDORSED_DIR%" -DdataAccessAPI.data="%DATA_DIR%" au.com.str.samples.schema.SinglebranchNavigation

Troubleshooting

The following are some errors you might encounter running the sample code.

ErrorIndicates that...
'ant' is not recognized as an internal or external command,
operable program or batch file.

Either Ant is not installed or you have not set your Path environment variable to include the location of the Ant executable.

Add Ant to your Path and try again.

Any changes you make to your system environment variables through the Windows Control Panel will not be picked up immediately by any running command prompt. You will need to close and reopen the command prompt to access the updated system environment variables.

Error occurred during initialization of VM 
java/lang/NoClassDefFoundError: java/lang/Object 

This error typically occurs if your Path system environment variable is not properly configured to point to the JDK.

Note that the Data Access API requires the full Java Development Kit (JDK), not just the Java Runtime Environment (JRE).

Exception in thread "main" 
au.com.str.superadmin.authentication.InvalidLoginCredentialsException:
Login incorrect

This error indicates that the Data Access API was unable to log in to SuperADMIN. This is most likely to be because the user credentials specified in the code are not valid for your system.

For example, SimpleTxdQuery uses the default administrator account to login. If you have changed the account password or removed this account from your system then you will need to update the credentials in SimpleTxdQuery.java and recompile:

  1. Open samples\au\com\str\samples\query\SimpleTxdQuery.java in a text editor.
  2. Locate the following line:

    CODE
    Connection ssConn = ConnectionFactory.newInstance().create("administrator", "administrator");
  3. Change the username and password to a valid account on your system. For example:

    CODE
    Connection ssConn = ConnectionFactory.newInstance().create("myuseraccount", "myuserpassword");
  4. Recompile the sample code (open a command prompt in the samples directory and run Ant).
  5. Run runSamples.bat.

 

Exception in thread "main" 
au.com.str.dataaccess.connection.NoSuchDatabaseException: census

This error indicates that the Data Access API has attempted to use a database that does not exist. In this case, the code is attempting to connect to a database with the ID census that does not exist.

To resolve this issue:

  1. Edit the code to change the ID of the database to a valid ID on your system.
  2. Recompile the code.
  3. Run the code again.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.