You can use a host variable to represent the database name you want your application to connect to. For example:
exec sql connect to :dbase;
If a host variable is specified:
dcl dbase char(10);
dbase = 'SAMPLE';    /*four blanks are */
                     /* automatically appended */ 
exec sql connect to :dbase;