Acceessing DB2 UDB in AIX COBOL on unix

Hi ,

We are migrating our database from DB2 z/os to DB2 UDB on UNIX.
and cobol on mainframes to AIX cobol on UNIX.

We have some cobol Db2 programs that are accessing different Databases
how do we code such type of programs in AIX cobol.

Do we need to Establish connection for accessing Each Tables

e.g

Table1 under Database1
Table2 under Database2

While Accessing These tables
do we need to connect to

connect to Database1

Exec SQL
select from table1
End-Exec

connect to Database2

Exec SQL
select from table2
End-Exec

Is this correct way for programming.
Is there any alternate approach for doing this.

and how do we compile such cobol and execute DB2 Programs.

Thanks,
Satish