通过MATLAB错误连接到postgresql数据库 [英] Connect to postgresql database via MATLAB error

查看:481
本文介绍了通过MATLAB错误连接到postgresql数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在MATLAB中连接我的Postgres数据库,它正在抛出一个错误,指出

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

'JDBC驱动程序错误: 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');

之后它会抛出错误。

我已经查看过论坛,他们告诉我将postgres jar文件添加到MATLAB目录工具包文本文件中,如下所示。

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.

谢谢。

推荐答案

文件与JDBC驱动程序连接到动态java类路径之前连接到数据库。我相信你可以根据你的要求只添加一个文件。请检查版本差异此处

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.

为避免警告,如果路径中的jar文件已添加一些检查:

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)
    javaaddpath(p)
end

这篇关于通过MATLAB错误连接到postgresql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆