MATLAB: Do I receive the error “Io Exception: Connection refused” with Oracle 10g and the Database Toolbox 3.1.1 (R2006a)

Database Toolbox

I am using the Query Builder from the Database Toolbox 3.1.1 (R2006a) to connect to my Oracle 10g database. Using the arguments as specified in the documentation, I get a dialog box with the following error:
Io Exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERF=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
If I use the DATABASE function with the following syntax:
conn = database('databasename','username','password','driver','databaseurl');
I get the following message in the database object, and the database is not opened:
Io Exception: The Network Adapter could not establish the connection

Best Answer

The issue is related to the incorrect usage of the DATABASE function. The DATABASE function expects the 'databasename' parameter to be the same as the SID parameter at the end of the 'databaseurl'. If the two are not the same, the 'databasename' is appended to the string in the 'databaseurl'.
In the Query Builder, the database 'Name' should be the same as the suffix after the port number in the database 'URL'
The correct syntax for the DATABASE function with Oracle 10g and the Thin Client JDBC drivers is
conn = database('databasename','username','password','oracle.jdbc.driver.OracleDriver',jdbc:oracle:thin:@IP_ADDRESS_OF_DATABASE_SERVER:1521:databasename');