首先,下载并按照驱动程序。
然后,edit classpath.txt,在最下面添加驱动程序的具体位置。
C:/Program Files/MATLAB/db_driver/mysql.jar
C:/Program Files/MATLAB/db_driver/pgsql.jar
使用方法:
For MySQL:
db_name = 'db_name';
db_user_name = 'db_user';
db_user_pass = 'db_user_pass';
db_server_ip = 'db_ip';
db_server_port = '3306';
url = strcat('jdbc:mysql://', db_server_ip, ':', db_server_port, '/');
dbh = database(db_name, db_user_name, db_user_pass, 'com.mysql.jdbc.Driver', url);
For PostgreSQL:
db_name = 'db_name';
db_user_name = 'db_user';
db_user_pass = 'db_user_pass';
db_server_ip = 'db_ip';
db_server_port = '5432';
url = strcat('jdbc:postgresql://', db_server_ip, ':', db_server_port, '/');
dbh = database(db_name, db_user_name, db_user_pass, 'org.postgresql.Driver', url);
阅读(1717) | 评论(0) | 转发(0) |