MATLAB: Do I receive an “The Network Adapter could not establish the connection” error message when connecting to Oracle 11g using JDBC 64-bit drivers in Database Toolbox R2017b

adapterconnectioncoulddatabaseDatabase ToolboxestablishNetworknotr2017bthetoolboxurl

I am trying to connect to Oracle Database using the following settings-
conn_string=['jdbc:oracle:thin:@',...
'(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)',...
'(HOST = nj******n.***.***)(PORT = 1521)))',...
'(CONNECT_DATA =(SERVICE_NAME = PEWS)))'];
 setdbprefs('DataReturnFormat','cellarray');
 conn = database('','****','***','Vendor','Oracle', 'URL',conn_string);
The connection is unsuccessful and I get the following error message-
'IO Error: The Network Adapter could not establish the connection'
I am able to connect to same Oracle Database from a sample Java application. 
But it will always error out while trying to connect from MATLAB.
How to fix this?

Best Answer

This error means that at least one of the parameters to the 'database' in incorrect.
Make sure that you are using correct values and are following the right syntax.
In your case, you are using URL as a name-value pair, which is wrong.
For JDBC connection, the possible name-value pair options are-
  • Vendor
  • Server
  • PortNumber
  • AuthType
  • DriverType
I order to use the URL, use the following syntax-
conn = database(<https://www.mathworks.com/help/database/ug/database.html?searchHighlight=database&s_tid=doc_srchtitle#inputarg_datasource datasource>,<https://www.mathworks.com/help/database/ug/database.html?searchHighlight=database&s_tid=doc_srchtitle#inputarg_username username>,<https://www.mathworks.com/help/database/ug/database.html?searchHighlight=database&s_tid=doc_srchtitle#inputarg_password password>,<https://www.mathworks.com/help/database/ug/database.html?searchHighlight=database&s_tid=doc_srchtitle#inputarg_driver driver>,<https://www.mathworks.com/help/database/ug/database.html?searchHighlight=database&s_tid=doc_srchtitle#inputarg_url url>)