Saving a Datasource programmatically

2 次查看(过去 30 天)
Dear Community,
I am currently at the basic level of using MATLAB to solve data analytics problems. This day I have been trying to connect to an Oracle Database in order to access available data tables, load and analyse certain portions of these data tables. I succesfully established a connection to the database as shown below, the connection does exist and is open.
I however have not been able to save this created conection ("DS_Conn") as a Datasource, so I can easily call it up through the datasource option in the Database Explorer Menu. Herewith is my editor code:
% Connect to oracle Database
datasource = 'DDSA_DB'
driver = 'oracle.jdbc.driver.OracleDriver'
url = ['jdbc.roacle.tin:@(DESCRIPTION = '
'(FAILOVER = ON)(LOAD_BALANCE = OFF)(ADDRESS_LIST ='
'(ADDRESS = (PROTOCOL = TCP)(HOST = XXX.XX.XX.XXX)(PORT = 1521)))'.
'CONNECT_DATA = SERVICE_NAME = DDSA)))'];
%
username = "XXXXXXX";
password = "xxxxxxxxxxx";
%
DS_Conn = database(datasource,username,password,dirver,url); % Connection established and is open [].
saveAsJDBCDataSource(DS_Conn); % Request fails with error message that "DS_Conn" is unknown.
%
Furthermore, a request to list all tables within the database accessible with my account only generates an error, despite existing database connection.
sql_select = sprintf(selectowner, table_name from all_tables); % error message
I most probably should be missing something, will very much appreciate your hints or any form of assistance.
P.S: Creating a connection using the "Database Explorer App" failed strangely enough, can't identify why.
Thanks
Desa

回答(1 个)

Sulaymon Eshkabilov
The last line in your posted code: saveAsJDBCDataSource() is not MATLAB's builtin fcn unless you have your own or 3rd party fcn file that has to be fixed.
  1 个评论
Lambert Desa
Lambert Desa 2021-7-5
Hello Sulaymon, Thanks for your Feedback, i initially requested:
saveAsDataSource(DS_Conn);
Yet it generated an error: "Unrecognized function or variable 'saveAsDataSource'. Reason why i tried to specify as 'saveAsJDBCDataSource'

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by