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
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)):
- 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.
类别
在 帮助中心 和 File Exchange 中查找有关 Reporting and Database Access 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!