我已经尝试使用
pgmex.不幸的是它不适用于libpq5(matlab立即崩溃).
解决方法
要在没有数据库工具箱的情况下从matlab连接到postgres,请执行以下操作:
% 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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。