MATLAB Answers


Why does a Oracle-DB-Connection can not be established with Matlab 2018?

Asked by Thomas Anvidalfarei on 9 May 2018
Latest activity Edited by Arpan Badeka on 29 Aug 2018
My function establishes a connection with an oracle database. Executing the following function (sorry, critical variables are defined with * here) with Matlab 2017a a connection can be established. The connection can not be established with Matlab 2018a. Can somebody help me out?
%%Vers. 2017/18
% DB settings
DB = '***';
user = '***';
password = '***';
vendor = 'Oracle';
dbConnStr = ['jdbc:oracle:thin:@(DESCRIPTION=' ...
%%In case add jdbcDriver
jdbcDriverPath = fullfile('jdbc_driver','ojdbc6.jar'); % jdbc_driver is a folder in pwd with ojdbc6.jar in it
if ~ismember(fullfile(matlabroot,'java','jar',jdbcDriverPath),...
javaclasspath('-static'))... % static
&& ~ismember(fullfile(pwd,jdbcDriverPath),...
javaclasspath('-dynamic')) % dynamic
%%Establish connection
conn = database(DB,user,password,...
%%Connection check
if isopen(conn)
msgbox('Connection OK');
msgbox('Connection FAIL')

  1 Comment

Can you please verify that the "databasename" field refers to the the instance name of your database and not the schema name?
Also ensure that you have added the full path of the JDBC driver to the classpath.txt file and verify the server name and port number for your Oracle database.

Sign in to comment.




1 Answer

Answer by Arpan Badeka on 22 Jun 2018
Edited by Arpan Badeka on 29 Aug 2018

Hi Thomas
The connection command used to setup the connection doesn’t seem to be correct. Please user either of the following commands to setup the connection:
datasource = 'dbname';
username = 'username';
password = 'pwd';
driver = 'oracle.jdbc.driver.OracleDriver';
url = 'jdbc:oracle:thin://host:port/dbname';
conn = database(datasource,username,password,driver,url)
datasource = 'toy_store';
conn = database(datasource,username,password,'Vendor','ORACLE', ...
'Server','dbtbxx','PortNumber',1521, ...
The command you are using seems to be a mix of the two syntax we currently support. Please try any of the above syntax to setup connection.
Arpan Badeka


Sign in to comment.