Working with connection specifications
The following examples show how to do the following:
Create a new connection specification
Display information about a connection specification
Change a connection specification
Turn off logon prompting for a connection specification
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 Visual Programming User 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.
 
"SQLite: Create a new connection specification to a file-based database stored in the current working directory named SAMPLE.”
| conSpec |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtSQLiteDatabaseManager
databaseName: 'SAMPLE'.
 
"SQLite: Create a new connection to an in-memory database.”
| conSpec |
conSpec := AbtDatabaseConnectionSpec
forDbmClass: #AbtSQLiteDatabaseManager
databaseName: ':memory:'.
 
"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.
 
Last modified date: 07/25/2020