Organizational Research By

Surprising Reserch Topic

connect to postgresql database via matlab error

connect to postgresql database via matlab error  using -'database,postgresql,matlab,jdbc,database-connection'

I am trying to connect my Postgres database in MATLAB and it is throwing me an error stating

"'JDBC Driver Error: org.postgresql.Driver. Driver Not Found/Loaded.'"

Here's my connection method that i have used.

conn = database('postgres','username','password','org.postgresql.Driver', 'jdbc:postgresql://localhost:5432/postgres=postgres');

after that it throws me the error.

I have looked at forums and they told me to add the postgres jar files to the MATLAB directory toolkit textfile, such as below.

C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc3.jar
C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc4.jar

I don't know where else I am going wrong. Please advise.

Thank you.

asked Oct 19, 2015 by r3tt
0 votes

Related Hot Questions

1 Answer

0 votes

You should add jar file with JDBC driver to your dynamic java class path before connecting to database. I believe you can add only one file depending on your requirements. Check the versions difference here.

To avoid warning if a jar file already in the path add some check:

%# add class path (if not in the class path)
p = 'C:\Program Files\PostgreSQL\pgJDBC\postgresql-8.4.702.jdbc3.jar';
if ~ismember(p,javaclasspath)
answered Oct 19, 2015 by sumit_jaiswalmca