PostgreSQL
 sql >> Cơ Sở Dữ Liệu >  >> RDS >> PostgreSQL

Làm cách nào để truy cập cơ sở dữ liệu postgresql từ matlab mà không có hộp công cụ cơ sở dữ liệu matlabs?

Để kết nối với postgres từ matlab mà không có hộp công cụ cơ sở dữ liệu, hãy làm điều gì đó tương tự như:

% Add jar file to classpath (ensure it is present in your current dir)
javaclasspath('postgresql-9.0-801.jdbc4.jar');

% Username and password you chose when installing postgres
props=java.util.Properties;
props.setProperty('user', '<your_postgres_username>');
props.setProperty('password', '<your_postgres_password>');

% Create the database connection (port 5432 is the default postgres chooses
% on installation)
driver=org.postgresql.Driver;
url = 'jdbc:postgresql://<yourhost>:<yourport>\<yourdb>';
conn=driver.connect(url, props);

% A test query
sql='select * from <table>'; % Gets all records
ps=conn.prepareStatement(sql);
rs=ps.executeQuery();

% Read the results into an array of result structs
count=0;
result=struct;
while rs.next()
    count=count+1;
    result(count).var1=char(rs.getString(2));
    result(count).var2=char(rs.getString(3));
    ...
end


  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. 2ndQuadrant tại PostgresConf US 2018

  2. PSQLException:Không tìm thấy tên cột clazz_ trong Tập kết quả này

  3. Flask-SQLAlchemy db.session.query (Model) so với Model.query

  4. Không còn dung lượng đệm (đã đạt đến kết nối tối đa?) Biểu mẫu Trình điều khiển Postgres EDB

  5. Lỗi cú pháp nhập không hợp lệ cho số nguyên đối với một số không phải là số nguyên?