Easysoft Data Access

How can I put attributes other than the DSN in my Perl DBI->connect call?

Last Reviewed:
4th July 2017

From DBD::ODBC 0.21, you can put all of the connection attributes specified in your odbc.ini file in the connection string passed to DBI->connect().

For example, suppose your odbc.ini file looked like this:

ServerPort = demo.easysoft.com:8888;
LogonUser = fred
LogonAuth = password
TargetDSN remotedsn

You can do away with the entire odbc.ini file and use the following Perl instead:

my $DSN = 'DRIVER={OOB};ServerPort=demo.easysoft.com:8888;';
$DSN = $DSN . 'LogonUser=fred;LogonAuth=password;TargetDSN=remotedsn';

my $dbh = DBI->connect("dbi:ODBC:$DSN",
          || die "Database connection failed: $DBI::errstr";

This can be particularly useful if you want to hide your usernames and password. For example, if you do not want them visible in the odbc.ini file. You could retrieve the username and password from somewhere else or even prompt for them.

Applies To

Knowledge Base Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)

Oracle is a registered trademark of Oracle Corporation and/or its affiliates.