trouble connecting to postgresql database from matlab
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Titus Edelhofer
el 2 de Mayo de 2011
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 comentarios
Ver también
Categorías
Más información sobre Database Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!