필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Thomas Anvidalfarei
Thomas Anvidalfarei 2018년 5월 9일
편집: Arpan Badeka 2018년 8월 29일
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=' ...
'(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=***)' ...
'(PORT=1521))(ADDRESS=(PROTOCOL=TCP)' ...
'(HOST=***)(PORT=1521)))'...
'(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCP)'...
'(INSTANCE_NAME=MULTITGP)))'];
%%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
javaaddpath(jdbcDriverPath);
end
%%Establish connection
conn = database(DB,user,password,...
'Vendor',vendor,...
'URL',dbConnStr);
%%Connection check
if isopen(conn)
msgbox('Connection OK');
close(conn);
else
msgbox('Connection FAIL')
end
  댓글 수: 1
Sharannya Ranjith
Sharannya Ranjith 2018년 5월 11일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Arpan Badeka
Arpan Badeka 2018년 6월 22일
편집: Arpan Badeka 2018년 8월 29일
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:
1.
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)
2.
datasource = 'toy_store';
conn = database(datasource,username,password,'Vendor','ORACLE', ...
'Server','dbtbxx','PortNumber',1521, ...
'DriverType','thin')
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.
Thanks,
Arpan Badeka

카테고리

Help CenterFile Exchange에서 Reporting and Database Access에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by