In this lesson, you will connect to the DB2® SAMPLE database and explore the actions that
are available for database connections.
The DB2 SAMPLE database
connection is displayed in the Data Source Explorer as a found connection
when you open the Data perspective. If the SAMPLE connection is not
displayed, you can explicitly connect to this database with a wizard.
You can view and modify preferences for database connections in the
Preferences window.
- View preferences for database connections:
- Click to open the Preferences
window.
- Expand Data Management. On
the DB2 Options preferences page, you can specify
options for the DB2 alias connections
that are created at startup. In this tutorial you will keep the default
preferences.
- Click Cancel to close the preferences
window.
- Connect to the DB2 SAMPLE
database. This action assumes that the connection was automatically
created and displayed in the Data Source Explorer when you started
the product. If the SAMPLE connection was not found, skip to the next
step to explicitly create a connection.
- Right-click the SAMPLE connection in the Data Source
Explorer, and select Connect.
- In the Properties for SAMPLE window,
enter a valid user ID and password, then click OK.
The connection icon changes to indicate that the database
is connected.
- Optional: If you do not see the SAMPLE database
in the Data Source Explorer, explicitly create a connection to the
database with the New Connection wizard.
- Click the New Connection Profile button
on the Data Source Explorer toolbar.
- On the Local tab, select DB2 for Linux®, UNIX®,
and Windows®. The
name of the database is SAMPLE by default.
The wizard selects the
default IBM® Data Server Driver
for JDBC and SQLJ (JDBC 4.0) to connect to the database. This driver
is included with the Optim™ Development
Studio. If you wanted to use a different version of the JAR files
for this version of the IBM Data
Server Driver for JDBC and SQLJ driver, you would click the Edit
the Location of the JDBC driver JAR files button [...]
to change these settings.
If you wanted to use a different
version of the IBM Data Server
Driver for JDBC and SQLJ driver, you could select it from the JDBC
driver field. Before you select the versions that use
Kerberos or LDAP security, you must configure your Kerberos or LDAP
environment.
You can also use the "Other Driver Default" driver
setting to use a JDBC driver of your choice.
JDBC tracing is set on the Tracing page
of the Connection URL details panel. JDBC tracing is useful for troubleshooting
connection problems, but tracing is not enabled by default so that
unnecessary log files are not generated. If you wanted to enable tracing,
you would clear the Disable Tracing check box
on the Tracing Options page, select which actions
to trace (for example, connection calls or statement calls), and specify
a file name for the log file.
- Type a valid user ID and password.
- Click Next. The wizard
verifies your connection information. If you entered an invalid user
ID or password you see an error message, otherwise the Data
Privacy Modeling page opens.
- Optional: On the Data Privacy
Modeling page, associate this connection with an existing
physical data model in a data design project. This association
is typically used to enable icons in views for columns in the database,
if these columns also correspond to columns in the model that have
been annotated with data privacy information. These icons help you
to quickly identify columns with associated data privacy policies.
You can also use this association to generate an Optim interchange file that contains data privacy
information when you are copying data objects.
This tutorial does
not explain data privacy modeling, so you can click Next.
- Optional: On the Filter page,
specify filtering options for the connection.
If you
wanted to filter the objects that are loaded for the connection, you
would clear the Disable filter check box. You
can select Expression to specify a filtering
expression, or you can select Selection to
select specific objects from the tree.
Tip: Adding
connection filters improves performance and simplifies the display
in the Data Source Explorer when you are connecting to large databases.
In addition to JDBC filtering for connections, you can also set data object filters in the Data Source Explorer
view.
You can add JDBC filtering after you have already created
a connection by right-clicking the connection in the Data Source Explorer
and selecting Properties, then modifying the
filter settings in the window that opens.
- Expand the database object, and browse the objects that
are contained in the database. The Data Source Explorer
displays data objects such as table spaces, schemas, and tables, and
privilege objects such as users and groups.
- Optional: Export the database connection information
to an XML file. You can use this feature to share database
connection information among team members, or to populate the Data
Source Explorer in a new workspace.
- Click the Export button (
) on the Data Source Explorer toolbar.
- In the window that opens, select the SAMPLE connection,
specify a file name (for example, myDB2connection)
and directory (for example, c:\temp).
The file is saved to the directory that you specified.
You can use this file to import the connection information to this
workspace or another Optim Development
Studio workspace.
- Optional: Import the database connection information
from the file that you created in the last step.
- Click to switch to another workspace.
- Click the Import button (
) on the Data Source Explorer toolbar.
- In the Import Connection Profiles window,
browse to the file that you created in the previous step, and click Open.
- Click OK.
The
SAMPLE database connection is displayed in the Data Source Explorer
in a disconnected state.
- Click and browse to your original workspace.
- Save the database information offline. You can
save database information so that you can view objects in a database
connection even when you do not have an active connection. You can
also use the saved information to develop data objects in a data development
project.
- Right-click the SAMPLE database connection in the Data
Source Explorer.
- Select Save Offline.
Attention: This action can take a long time for large databases.
A progress window opens to indicate that the database
information is being saved.
Now you can use the saved information to work offline. Some
actions, such as dropping data objects, cannot be performed with an
offline connection.
- Right-click the SAMPLE database connection again, and select Work
Offline. You can browse the database
objects in the disconnected database connection, and view their properties
in the Properties view.
- Reconnect to the SAMPLE database by right-clicking it and
selecting Connect.