Setting up the Bank Example

About the bank example

Chapters 4, 5, and 6 of this guide present a deeper CORBA development example than the Hello World example we saw in chapter 2. The new example is a simple implementation of a bank. The architecture of the bank has three components:

  • A database that provides persistent storage for the accounts managed by the bank.

  • A CORBA server that represents the bank and provides an object-oriented interface to its accounts.

  • A CORBA client that provides a graphical user interface to the bank.

This application is a typical example of a three-tier application architecture comprising a database access layer, a business logic layer, and a user interface layer.

Accounts are stored as records in a Microsoft Access™ relational database. The database is manipulated by the server using the Open Dylan SQL-ODBC library.

The server provides a single CORBA object that represents the bank. This object manages a collection of CORBA objects that represent customer accounts. The bank has operations for opening and closing accounts, and for retrieving existing accounts from the database. In turn, accounts support operations for querying and updating their balance.

The client initially contacts the server by obtaining a reference to the bank object from the Open Dylan ORB. It then presents the user with a graphical interface to the bank.

In response to user requests, the interface invokes operations on the bank, obtaining further references to accounts created on the server. The client manages separate windows for the bank and each of the accounts that are active in the server.

We will use the Open Dylan DUIM library to implement the client’s user interface.

Where to find the example code

The bank example code is available in the Open Dylan Examples menu, under the CORBA category. There is a Bank Client project and a Bank Server project.

The same code is also available in the top-level Open Dylan installation folder, under Examples\corba\bank. This folder has several subfolders.

  • Examples\corba\bank\bank contains the file bank.idl. This is the IDL file declaring the CORBA interface to the server.

  • Examples\corba\bank\bank-client contains the implementation of the client as project bank-client.hdp.

  • Examples\corba\bank\bank-server contains the implementation of the server as project bank-server.hdp. This folder also contains a ready made Microsoft Access database file bankDB.mdb. The application uses this to record bank account details.

ODBC requirements

In order to run the example, you need to have ODBC version 3.0 (or higher) and an ODBC driver for Microsoft Access installed on the machine hosting the server application. You do not need a copy of Microsoft Access.

Both ODBC 3.x and the Microsoft Access driver are available free for download from Microsoft Access Database Engine 2010 Redistributable download page, <https://www.microsoft.com/en-us/download/details.aspx?id=13255>.

This information may change in the future.

Registering the database with ODBC

So that the bank server can access the bank.mdb database using ODBC, we need to register the database as an ODBC data source. This installation step also tells ODBC which driver to use when connecting to the database.

To register the database in this way, ODBC drivers must be installed on the machine that will host the server.

Registering the database on Windows 10

To register the bank.mdb database with ODBC on Windows 10:

  1. From the Windows Start menu, choose Windows Administrative Tools ‣ ODBC Data Sources (32-bit)

    The ODBC Data Source Administrator appears.

  2. Select the User DSN tab.

  3. Click Add….

  4. Select Microsoft Access Driver from the list of available drivers.

  5. Click Finish.

    The ODBC Microsoft Access Setup dialog appears.

  6. In the ODBC Microsoft Access Setup dialog, enter bankDB in the Data Source Name field.

  7. Click Select….

    The Select Database dialog appears.

    We can now specify the database file name. The file is stored under the top-level Open Dylan installation folder, in the subfolder Examples\corba\bank\bank-server.

  8. In the Select Database dialog, browse until you reach the folder above.

  9. Select bankDB.mbd from the list of available files, then click OK .

  10. Click OK again to close the ODBC Microsoft Access Setup dialog.

  11. Click OK to close the ODBC Data Source Administrator.

    We also need to ensure that the bank.mdb file is writable.

  12. Right-click on the file in a Windows Explorer window.

  13. Select Properties from the shortcut menu.

  14. Clear the Read-only attribute if it is checked, and click OK.

The ODBC setup work for the demo is now complete. We can move on to building and running the demo itself.

Building the Bank client and server

We can now build the client and server applications for the demo.

  1. Start the Open Dylan environment.

    The client and server projects are available in the Examples dialog. Choose Help ‣ Open Example Project… from the main window.

  2. In the Examples dialog, open the Bank-Client project.

  3. In the Bank-Client project window, choose Project ‣ Build.

    The IDL compiler, Scepter, is invoked automatically during the build process. It compiles the file bank.idl to generate the source code for the protocol and stubs libraries.

  4. Bring up the Examples dialog again, and open the Bank-Server project.

  5. In the Bank-Server project window, choose choose Project ‣ Build.

Running the server and client

We can now run the bank demo for the first time.

In the Bank-Server project window, choose Application ‣ Start to run the server executable. The server is represented by an administration window with a raw table of the database contents, a log window for seeing requests, and a couple of menu items.

Once you have finished interacting with the bank, click the close button in the top right-hand corner of this bank server window to exit. Do not do this yet.

Once the server’s dialog has appeared, go to the Bank-Client project window and choose Application ‣ Start to run the executable for the client. A window presenting a GUI to the bank should appear.You can now interact with the bank to create new accounts, deposit amounts, and so on.

Once you have finished interacting with the bank, click the close button in the top right-hand corner of the bank window to exit the client application. Then do the same for the server window.