Database Guide

Working with active connections

The following examples show ways that you can work with an active database connection:

"Connect to a database.  Return the name of the database."
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
     (conSpec connect) dataSourceName.
    
"Connect to a database.  Ask if the database contains
a given table name."
| conSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
     (conSpec connect) tableOrViewExistsNamed: 'ORG'.
 
"If there is only one active connection, return the
connection.  If there is no active connection, return
nil.  If there is more than one active connection,
return the first one that was activated."
AbtDbmSystem activeDatabaseConnection.
 
"Connect to a database with the alias SampleConSpec.
Return the active database connection with the
given alias."
| conSpec logonSpec |
conSpec := AbtDatabaseConnectionSpec
     forDbmClass: #AbtIbmCliDatabaseManager
     databaseName: 'SAMPLE'.
logonSpec := AbtDatabaseLogonSpec
     id: 'userid'
     password: 'password'
     server: nil.
conSpec connectUsingAlias: 'SampleConSpec'
     logonSpec: logonSpec.
AbtDbmSystem activeDatabaseConnectionWithAlias: 'SampleConSpec'.
 


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