如何在没有matlabs数据库工具箱的情况下从matlab访问postgresql
发布时间:2021-04-02 11:07:51 所属栏目:MsSql教程 来源:网络整理
导读:我已经尝试使用 pgmex.不幸的是它不适用于libpq5(matlab立即崩溃). 解决方法 要在没有数据库工具箱的情况下从matlab连接到postgres,请执行以下操作: % Add jar file to classpath (ensure it is present in your current dir)javaclasspath('postgresql-9.0-
|
我已经尝试使用 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 (编辑:均轻资讯网_我爱站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
- sql – 深度嵌套的子查询因子分解(CTE)的性能降低
- @OrderBy导致java.lang.ClassCastException:ant
- 在现有数据库中创建ASP.Net成员资格数据库结构
- 为了将数据存储到数据库中,在PHP中使用序列化是一
- ms-access – 如何控制Access数据库的用户权限?
- sql-server – 使用GUI恢复数据库 – 要恢复的文
- sql-server – 一个事务中SQL Server中的备用同义
- sql-server-2008 – 通过存储过程模拟TSQL序列
- sqlserver中事务和锁怎样理解?一文带你看懂事务
- html中table固定头部表格tbody可上下左右滑动
热点阅读

