Database Guide

Working with connection specifications

The following examples show how to do the following:

You can execute each of these examples by copying them to a workspace and evaluating them with the Execute command.

For the ODBC sample, you need to have an existing ODBC data source. Refer to the VisualAge for Smalltalk User's Guide for information on setting up ODBC data sources.

"Create a new connection specification"
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
 
"Create a new connection specification and add
information about the connection specification
to a dictionary.  Return the dictionary."
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
     (Dictionary new) at: 'Database' put: (conSpec databaseName);
                             at: 'DBManager' put: (conSpec dbmClass);
                             at: 'Prompt?' put: (conSpec promptEnabled);
                             yourself.
 
"Create a new ODBC connection specification and add
information about the connection specification
to a dictionary.  Return the dictionary.
This block of code works only if you have already
defined an ODBC data source."
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtOdbcDatabaseManager
     dataSourceName: 'ODBCSamp'.
     (Dictionary new) at: 'Data Source' put: (conSpec dataSourceName);
                             at: 'DBManager' put: (conSpec dbmClass);
                             at: 'Prompt?' put: (conSpec promptEnabled);
                             yourself.
 
"Create a new connection specification, then change
information about the connection specification."
| conSpec newConSpec|
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
     newConSpec := conSpec databaseName: 'ORDERENT';
                               dbmClass: AbtOdbcDatabaseManager.
 
"Turn off the logon prompt for a connection specification"
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
     conSpec promptEnabled: false.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]