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
0 个评论
回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!