unable to connect to AWS MySQL and PostgreSQL

7 views (last 30 days)
I created AWS databases both MySQL and PostgreSQL. I collected endpoints, ports, and credentials. I downloaded the latest JDK and the lastest few drivers to experiment. My attempts to connect fail. I loaded drivers from the link provided in the matlab documentation (https://www.mathworks.com/products/database/driver-installation.html). I am new at this. I am working on both an imac and a windows machine. Any guidance?
Example:
opts = configureJDBCDataSource("Vendor","PostgreSQL");
endpoint = "XXXX.us-east-2.rds.amazonaws.com";
connector = "/XXXX/postgresql-42.2.9.jre7.jar";
opts = setConnectionOptions(opts ,...
"DataSourceName","SQL" ,...
"Server", endpoint ,...
"PortNumber", 5432 ,...
"JDBCDriverLocation", connector );
username = "XXXX";
password = "XXXX";
[status,msg] = testConnection(opts,username,password)
'JDBC Driver Error: The connection attempt failed.'
'JDBC Driver Error: No suitable driver found for XXXX.us-east-2.rds.amazonaws.com'
etc
  2 Comments
scott sims
scott sims on 17 Jan 2020
Edited: scott sims on 17 Jan 2020
I sent a comprehensive response but it got deleted two different ways in firefox. Also an imac+chrome wont allow copying. I got this to work too bad I can't illustrate. There are a bunch of extra largely undoccumented both matlab and AWS settings required. No time at the moment to figure out why this reporting interface won't allow me to respond properly...

Sign in to comment.

Accepted Answer

scott sims
scott sims on 17 Jan 2020
From a different resource I believe I can submit the answer. First I used several versions including the latest 19b and serval platforms.
I found the matlab documentation to be somewhat deficient. Additional arguments are required especially the secondary database name as "DatabaseName". i also noted that if example doccumentation is followed such that "DataSourceName" is distinct from "DatabaseName" that introduce a second connection.
Critical non-default AWS settings included setting public accessibly to true, at database creation asserting secondary database name to instantiate the database (a nearly hidden setting with unexpected behavior), and modifying security group inbound/outbound constraints to accept the IP of my desktop as a client.
I found this AWS resources to be particularly valuable despite it addressing an obsolete RDS dashboard.
Here is the working code:
%_________________________________
%resource credential specification
username = "XXXX";
password = "XXXX";
%______________________
%resource specification
databasename = 'myDB';
endpoint = 'XXX.us-east-1.rds.amazonaws.com';
connector = '/Users/XXX/Desktop/postgresql-42.2.9.jar';
if 0
javaaddpath(connector)
end
%___________________
%resource aquisition
if 1
%_______________
%database target
opts = configureJDBCDataSource("Vendor","PostgreSQL");
opts = setConnectionOptions(opts ,...
"DatabaseName",databasename ,...
"DataSourceName",databasename ,...
"Server", endpoint ,...
"PortNumber", 5432 ,...
"JDBCDriverLocation", connector );
disp(opts)
%_________________________
%database link confimation
[status,msg] = testConnection(opts,username,password);
if 1
disp('status:')
disp(status)
disp('message:')
disp(msg)
end
%________________________________
%database reference establishment
saveAsJDBCDataSource(opts)
end
%___________________
%resource connection
dcon = database(databasename,username,password);
  1 Comment
scott sims
scott sims on 17 Jan 2020
Could TMW put together a demo that connects to any common cloud database? To me that seems a natural stating point.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!