trouble connecting to postgresql database from matlab

조회 수: 11 (최근 30일)
Prabir Barooah
Prabir Barooah 2011년 5월 2일
I'm trying to connect to a postgresql database in my local machine from matlab, and I'm getting the 'connection attempt failed' error message. I've tried and checked various things after reading up on the net but haven't been able to resolve the problem. Here are the details.
OS - MAC OS X version 10.6.6.
matlab version: (it's a 32 bit version though my machine is a 64 bit one) ------------------------------------------------------------------------------------- MATLAB Version 7.9.0.529 (R2009b) MATLAB License Number: DEMO Operating System: Mac OS X Version: 10.6.6 Build: 10J567 Java VM Version: Java 1.6.0_24-b07-334-10M3326 with Apple Inc. Java HotSpot™ Client VM mixed mode ------------------------------------------------------------------------------------- Database Toolbox Version 3.6 (R2009b) -----------
postgresql version: 9.0.3
----- here's the matlab code:
%% datasourcename = 'baclog';
driver ='org.postgresql.Driver';
databaseurl = 'jdbc:postgresql://masd/MOSE';
conn = database(datasourcename,'postgres',passwd,driver,databaseurl); %% end of matlab code
the database name is 'backlog', the password supplied in in the string variable passwd for the user 'postgres' is correct (I can connect to the database though a terminal using this password). The 'conn' object shows that connection failed: conn =
Instance: 'baclog'
UserName: 'postgres'
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: 'The connection attempt failed.'
Handle: 0
TimeOut: []
AutoCommit: 'off'
Type: 'Database Object'
The path to .jar files were added to the classpath.txt file in the matlabroot/.… folder, and when I type 'javaclasspath' in the matlab command window I get the following, apart from a bunch of other stuff:
/Applications/PostgreSQL/pgJDBC/postgresql-9.0-801.jdbc4.jar
and the path is correct, that's where the .jar file is. This makes me believe matlab knows where the .jar files are, so that shouldn't be a problem. BTW, I also tried using the jdbc3 driver (using the file 'postgresql-9.0-801.jdbc3.jar' file in the /Applications/PostgreSQL/pgJDBC/ folder and putting that path in the classpath.txt. I've also tried changing the authentication method to "trust" in pg_hba.conf instead of the default 'md5' that requires password authentication. No difference.
Any ideas on how to fix this will be most welcome. Prabir

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 5월 2일
Hi,
in conn we see the database name "baclog", but you said, the name is "backlog"? Otherwise the code looks fine on first sight ...
Titus
  댓글 수: 2
Prabir Barooah
Prabir Barooah 2011년 5월 2일
sorry, my mistake ; the k was a typo. The database name is baclog, without the k. So the problem remains.
Oleg Komarov
Oleg Komarov 2011년 5월 2일
Maybe firewall?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by