Matlab generates a wrong oracle database url
Show older comments
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?
Answers (1)
Fabian Wendt
on 27 Apr 2021
0 votes
Hi,
There are two notations for connection with a thin driver to an Oracle database (see also JDBC - Oracle FAQ (orafaq.com)):
- SID (old not recommended): jdbc:oracle:thin:[<user>/<password>]@<host>[:<port>]:<SID>
- 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.
Categories
Find more on Reporting and Database Access in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!