Easysoft ODBC-ODBC Bridge

Why does Perl DBD::ODBC appear to open the DEFAULT data source with OOB?

Article:
00097
Last Reviewed:
19th July 2005
Revision:
1

Since DBD::ODBC 0.21, Perl has required an ODBC driver manager (or at least some of the functions a Driver Manager supplies). In addition, since 0.21 the DBD::ODBC module connection code (dbdimp.c) started calling SQLDriverConnect first with your DSN name and only if that failed called SQLConnect with the same DSN name. The problem is that SQLDriverConnect is supposed to take a list of attributes of the form:

attribute=name;

and a DSN should be specified as "DSN=name;". Perl DBD::ODBC does not appear to append the "DSN=" to the DSN before calling SQLDriverConnect and so the OOB follows ODBC and assumes a DSN=DEFAULT. If the DEFAULT DSN is not found (likely), DBD::ODBC tries calling SQLConnect with the same DSN name but SQLConnect only takes a DSN name and does not require the "DSN=" so this tends to work.

Ifthe time taken to go through this process bothers you change the name on your calls to DBI->connect to "DBI:ODBC:DSN=dsnname". However, one warning here; the db username and db password (second and third arguments to DBI->connect) are ignored when using SQLDriverConnect so you need to put UID=dbuser;PWD=dbpass into the connection string if your database engine requires authentication.

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.