MTS Sample Bank
This sample is located in the \Samples folder of the MTS installation directory.
Note This sample is designed to run on operating systems prior to Microsoft® Windows® 2000.
Description
Setting Up the Sample
Building MTS Components in Java
Key Project Files
Technologies Demonstrated
Description
The Microsoft® Transaction Server (MTS) Sample Bank application is a banking services application that credits, debits, and transfers money between accounts. Running the Sample Bank application allows you to test your installation of MTS with Microsoft® SQL Server, version 6.5, as well as practice package deployment and administration. Sample Bank has components written in Microsoft® Visual Basic®, Microsoft® Visual C++®, and Microsoft® Visual J++®.
This topic provides instructions for setting up the Sample Bank application and performing some basic operations with it. The Microsoft Transaction Server Programmer’s Guide provides an extensive tutorial describing how to build Sample Bank components, including how to build components using Java. This guide is part of the MSDN Library.
Setting Up the Sample
To set up the Sample Bank application
- Install the MTS development samples and documentation using the Custom setup option and choosing all MTS subcomponents.
- Set up the Data Source Name (DSN).
- Install the Sample Bank package.
- Set up the MTS Explorer to monitor the Sample Bank package.
- Run the Bank Client.
The following sections describe these steps in detail.
To install the MTS development samples and documentation
Select the Custom option when you run the MTS setup program and select all MTS subcomponents. The Custom option installs the MTS run-time environment, MTS Explorer, MTS core documentation, MTS development samples, and MTS development documentation.
Reviewing the MTS development samples and documentation will provide a more thorough understanding of the packages and components that you manage. The sample applications will also help you confirm that you have correctly installed MTS.
If you have already installed MTS without the development samples and documentation, you can obtain these components by doing the following.
- On the Start menu, click Settings, and then click Control Panel.
- Select the Add/Remove Programs option, click Microsoft Transaction Server, and then click the Add/Remove button.
Note that if you uninstall MTS, user-defined packages will be removed. If you want to maintain your user-defined packages, do the following to install MTS without removing the previous installation.
- From the setup program, select the Reinstall/Add button.
- Select the Microsoft Transaction Server option, and click the Show Subcomponents button.
- Verify that all MTS subcomponent check boxes have been selected, and then click OK.
To set up the DSN
MTS automatically configures the ODBC data source for Sample Bank during setup. Because the local computer is used by default, you must have SQL Server, version 6.5, installed on your local computer.
By default, the MTS DSN points to SQL Server 6.5. If you are using a database other than SQL Server 6.5, you must delete the DSN and add a new DSN called MTSSamples that points to your database.
If you want to use a SQL Server installation on another computer, use the ODBC service icon in the Control Panel to modify your data source as follows:
- In the Data Sources dialog box, click the File DSN tab, and select the MTSSamples data source.
- Click Configure and then enter the name of the server you want to use.
Note that the Login ID and Password specified by the MTSSamples DSN are not used by Sample Bank. Sample Bank uses the account named sa and the null password. If your system administrator password is non-null or you want to specify a different login ID, you must modify the ODBC connection string in the Sample Bank source code.
To install the Sample Bank package
- In the left pane of MTS Explorer, select the computer on which you want to create a package.
- Open the Packages Installed folder for that computer.
- On the Action menu, click New. (You can also select the Create New Object button on the MTS toolbar, or right-click on the Packages Installed folder and select New, and then select Package.)
- Click the Install Pre-Built Packages button.
- In the Select Package Files dialog box, click Add to browse the network for available package files. Select the package file (.pak) for the Sample Bank application, click Open, and then click Next. Note that you can install multiple packages at the same time. The component files that are included in the package must be located in the same directory as the package file.
- Specify the package identity in the Set Package Identity dialog box, and then click Next. The default selection is Interactive User. The interactive user is the user who logged on to the Microsoft® Windows NT® account for the computer that runs a package. You can select a different user by selecting the This user option and entering details for a specific Windows NT user.
- In the Installation Options dialog box, specify the installation directory. The component files are copied from the package file directory to the installation directory. You can accept the default directory, or click Browse to search for another location.
- If the package file you are installing contains defined Windows NT users, the Add Windows NT Users Saved in the Package File option will be available. Clicking this box adds these users to the new package.
- Click Finish. The Explorer hierarchy now shows the new package in the right pane. If you install multiple packages, the options you choose in steps 6 and 7 apply to all the packages.
In Windows NT, you can also install a pre-built package by dragging a package file from the Windows NT Explorer to the right pane of the MTS Explorer while the Packages folder of a computer is open.
To monitor the Sample Bank package components and transactions
- Double-click the Sample Bank package icon in the right pane of the MTS Explorer.
- Double-click the Components folder.
- On the View menu, click Status View to display usage information for the various components in the package.
- On the Window menu, click New Window.
- Re-arrange the new window so the two windows do not overlap. You can stack different windows by selecting either the Cascade or Tile Horizontally options from the Window menu.
- Click Transaction Statistics in the left pane of the new window.
- On the Action menu, click Scope to clear the check mark and hide the left pane. Transactions statistics are now displayed when transactional components are used.
To run the bank client
- Make sure that Microsoft Distributed Transaction Coordinator (MS DTC) is running. If it isn't, select My Computer in the left pane of the Transaction Server Explorer. Open the Action menu and click Start MS DTC (if that option is enabled).
- Make sure that SQL Server is running. You can start SQL Server from Control Panel.
- On the Start menu, point to Programs, point to Microsoft Transaction Server, point to Samples, and then click Bank Client. Arrange the Bank Client window so it doesn't overlap the MTS Explorer windows.
- The form will default to credit $1 to account number 1. Click Submit. You should see a response with the new balance.
- Observe the MTS Explorer windows. You will notice that the component usage and transaction statistics windows have been updated.
- Experiment with the bank client and observe the statistics using different transaction types, servers, and iterations. The first transaction takes longer than subsequent transactions for the following reasons:
- The first transaction is creating the sample bank database tables and inserting temporary records.
- Beginning the server process consumes system resources.
- Opening database connections for the first time is a costly server operation.
Building MTS Components in Java
For detailed instructions on building MTS components in Java, see the following documentation:
- Integrating Java and Microsoft Transaction Server, which is included in the Integration.chm file located in the %SDKDIR%\Docs directory.
- Microsoft Transaction Server Programmer's Guide, which is included in the MSDN Library. The programmer's guide also contains a complete tutorial on creating MTS components.
To rebuild the Java Sample Bank components
The Java Sample Bank components are automatically configured by MTS setup and require no additional steps to run. If you change these components or add new ones, however, use the following steps.
- Run the SetJavaDev.bat file located in the \Mts\Samples\Account.vj folder. Javatlb.exe must be in your path for this batch file to run properly.
- Recompile your Java component implementation classes.
- After you recompile the component classes, use the Mkdll.bat file located in the \Mts\Samples\Account.vj folder to generate and register Vjacct.dll. Exegen.exe must be in your path for this batch file to run properly. You can also add running Mkdll.bat as a build step to your Visual J++ project to simplify recompiling.
- Using the MTS Explorer, import the new components into the Sample Bank package.
Key Project Files
Account.java
This class implements the Account component. The truePost method performs the work of the class: it obtains the database connection, retrieves and uses account information, and then releases the database connection. The Post method performs error handling for truePost.
MoveMoney.java
This class implements the MoveMoney component. It creates the account object, performs credit, debit, and transfer operations, and then creates a Receipt object. The truePerform method does the work of this class and the Perform method handles errors.
GetReceipt.java
This class implements the Receipt component, which dispenses unique receipt numbers for each monetary transaction. The trueGetNextReceipt method does the work of this class. Two versions of this method are provided: the first version uses the MTS Shared Property Manager to hold the shared state; the second version uses Java static variables to hold the shared state and a static synchronized method to access and update it. The GetNextReceipt method performs error handling for trueGetNextReceipt.
UpdateReceipt.java
This class implements the UpdateReceipt component, which stores a maximum receipt number in a database. When this maximum is reached, which happens on every one-hundredth transaction, UpdateReceipt adds 100 to the maximum receipt value and updates the database. The trueUpdate method does the work of this class and the Update method handles errors.
Technologies Demonstrated
MTS
- Building MTS application components with Java.
© 1999 Microsoft Corporation. All rights reserved. Terms of use.