Matlab generates a wrong oracle database url

I try to connect to an Oracle database (ojdbc8). The following lines work fine:
url='jdbc:oracle:thin:@servername:1532/SID';
driver='oracle.jdbc.driver.OracleDriver';
conn = database('databasename','username','password',driver,url)
However using the following one
conn = database('databasename','username','password','Vendor','Oracle','Server','servername','PortNumber',1532,'DriverType','thin')
generates an error message
'Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descripto'.
It appears than that the Matlab function database.internal.utilities.DatabaseUtils.getDatabaseURL(vendor) generates the wrong url: 'jdbc:oracle:thin:@servername:1532:SID' instead of 'jdbc:oracle:thin:@servername:1532/SID. I tried also to use the app Database Explorer and got the same error. I guess this is due to the same problem. How to change the way Matlab generates the url?

답변 (1개)

Fabian Wendt
Fabian Wendt 2021년 4월 27일

0 개 추천

Hi,
There are two notations for connection with a thin driver to an Oracle database (see also JDBC - Oracle FAQ (orafaq.com)):
  1. SID (old not recommended): jdbc:oracle:thin:[<user>/<password>]@<host>[:<port>]:<SID>
  2. Service: jdbc:oracle:thin:[<user>/<password>]@//<host>[:<port>]/<service>
This is probably where the confusion is coming from. As using the service name is better I think MATLAB should update this.

카테고리

도움말 센터File Exchange에서 Reporting and Database Access에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2020년 5월 13일

답변:

2021년 4월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by