None

ORA-06401: NETCMN: invalid driver designator

January 6, 2010

I was getting the error cx_Oracle.DatabaseError: ORA-06401: NETCMN: invalid driver designator when connecting to an Oracle database from my python script. This seems to only happen when I'm on the VPN.

Here's the code that connects to the database and exhibits this problem:

lConnectString = "%s/%s@%s:%d/%s" % (lDatabaseUsername, 
                                     lDatabasePassword, 
                                     lDatabaseHost, 
                                     int(lDatabasePort),
                                     lDatabaseName)
self.dbConnection = cx_Oracle.connect(lConnectString)

This problem can be sorted by using a function in the cx_Oracle driver to create the portion of the connect string after the @ sign.

lDsn = cx_Oracle.makedsn(lDatabaseHost, int(lDatabasePort), lDatabaseName)
lConnectString = "%s/%s@%s" % (lDatabaseUsername, lDatabasePassword, lDsn)
self.dbConnection = cx_Oracle.connect(lConnectString)

This creates the following connect string:

username/password@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=dbhost)(PORT=1521)))(CONNECT_DATA=(SID=DATABASE_NAME)))

instead of the previous:

username/password@dbhost:1521/DATABASE_NAME