Matlab connection string to a local Postgres Db

27 ビュー (過去 30 日間)
Paul Efford
Paul Efford 2023 年 5 月 15 日
編集済み: Paul Efford 2023 年 5 月 15 日
I have created a local Postgres Db on my computer, from where I am also running Matlab R2021b.
How can I set up a connection string to connect to my Db?

採用された回答

Paul Efford
Paul Efford 2023 年 5 月 15 日
dbname = 'myDbName'; % = datasource
username = "postgres";
password = 'admin';
server = 'localhost'; % 127.0.0.1'; % 'server' = 'hostname'
port = '5432';
driver = 'org.postgresql.Driver';
url = ['jdbc:postgresql://' server ':' port '/' dbname];
try
conn = database(dbname, username, password, driver, url);
conn.AutoCommit = "off";
%conn.LoginTimeout = 0;
%conn.MaxDatabaseConnections = 100;
if isopen(conn)
disp('Database connection successful');
%... put your queries here
close(conn); % close the database connection
else
disp('Database connection failed');
end
catch ME
disp(['Error while processing data from file ' ': ' ME.message]);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by