필터 지우기
필터 지우기

Saving a Datasource programmatically

조회 수: 6 (최근 30일)
Lambert Desa
Lambert Desa 2021년 7월 4일
댓글: Lambert Desa 2021년 7월 5일
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
Sulaymon Eshkabilov 2021년 7월 4일
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