Effacer les filtres
Effacer les filtres

Saving a Datasource programmatically

6 vues (au cours des 30 derniers jours)
Lambert Desa
Lambert Desa le 4 Juil 2021
Commenté : Lambert Desa le 5 Juil 2021
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

Réponses (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 4 Juil 2021
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 commentaire
Lambert Desa
Lambert Desa le 5 Juil 2021
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'

Connectez-vous pour commenter.

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by