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?

Risposte (1)

Fabian Wendt
Fabian Wendt il 27 Apr 2021
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.

Categorie

Scopri di più su Reporting and Database Access in Centro assistenza e File Exchange

Prodotti

Release

R2018b

Richiesto:

il 13 Mag 2020

Risposto:

il 27 Apr 2021

Community Treasure Hunt

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

Start Hunting!

Translated by