- 浏览: 4332405 次
- 性别:
- 来自: 湛江
博客专栏
-
SQLite源码剖析
浏览量:79402
-
WIN32汇编语言学习应用...
浏览量:68357
-
神奇的perl
浏览量:101480
-
lucene等搜索引擎解析...
浏览量:281131
-
深入lucene3.5源码...
浏览量:14596
-
VB.NET并行与分布式编...
浏览量:65547
-
silverlight 5...
浏览量:31310
-
算法下午茶系列
浏览量:45197
文章分类
最新评论
-
yoyo837:
counters15 写道目前只支持IE吗?插件的东西是跨浏览 ...
Silverlight 5 轻松开启绚丽的网页3D世界 -
shuiyunbing:
直接在前台导出方式:excel中的单元格样式怎么处理,比如某行 ...
Flex导出Excel -
di1984HIT:
写的很好~
lucene入门-索引网页 -
rjguanwen:
在win7 64位操作系统下,pygtk的Entry无法输入怎 ...
pygtk-entry -
ldl_xz:
http://www.9958.pw/post/php_exc ...
PHPExcel常用方法汇总(转载)
1、连接数据库
1)相关参数
help database
Database Toolbox
Version 3.7 (R2010a) 25-Jan-2010
General functions:
chkprops - Database object properties.
logintimeout - Set or get time allowed to establish database connection.
setdbprefs - Set preferences for database actions for handling null values.
Database Access functions:
database/catalogs - Get database catalog names.
database/clearwarnings - Clear warnings for database connection.
database/close - Close database connection.
database/columns - Get database table column names.
database/commit - Make database changes permanent.
database/database - Connect to database.
database/exec - Execute SQL statement and open cursor.
database/fetch - Import data into MATLAB using connection handle.
database/get - Get database property.
database/insert - Export MATLAB cell array data to database table.
database/isconnection - Detect if database connection is valid.
database/isreadonly - Detect if database connection is read-only.
database/ping - Get status information about database connection.
database/rollback - Undo database changes.
database/runstoredprocedure - Stored procedures with input and output parameters.
database/schemas - Get database schema names.
database/set - Set properties for database connection.
database/sql2native - Convert JDBC SQL grammar into system's native SQL grammar.
database/tables - Get database table names.
database/update - Replace data in database table with data from MATLAB cell array.
Database Cursor Access functions:
cursor/attr - Get attributes of columns in fetched data set.
cursor/close - Close cursor.
cursor/cols - Get number of columns in fetched data set.
cursor/columnnames - Get names of columns in fetched data set.
cursor/fetch - Import data into MATLAB.
cursor/get - Get property of cursor object.
cursor/querytimeout - Get time allowed for a database SQL query to succeed.
cursor/rows - Get number of rows in fetched data set.
cursor/set - Set RowLimit for cursor fetch.
cursor/width - Get width of column in fetched data set.
Database Toolbox Object functions:
dbtbx/dbtbx - Construct Database Toolbox object.
dbtbx/display - Database Toolbox object display method.
/dbtbx/subsasgn - Subscripted assignment for Database Toolbox object.
dbtbx/subsref - Subscripted reference for Database Toolbox object.
Database Toolbox Database MetaData functions:
dmd/bestrowid - Get database table unique row identifier.
dmd/columnprivileges - Get database column privileges.
dmd/columns - Get database table column names.
dmd/crossreference - Get information about primary and foreign keys.
dmd/dmd - Construct database metadata object.
dmd/exportedkeys - Get information about exported foreign keys.
dmd/get - Get database metadata properties.
dmd/importedkeys - Get information about imported foreign keys.
dmd/indexinfo - Get indices and statistics for database table.
dmd/primarykeys - Get primary key information for database table or schema.
dmd/procedurecolumns - Get catalog's stored procedure parameters and result columns.
dmd/procedures - Get catalog's stored procedures.
dmd/supports - Detect if property is supported by database metadata.
dmd/tableprivileges - Get database table privileges.
dmd/tables - Get database table names.
dmd/versioncolumns - Get automatically updated table columns.
Database Toolbox Driver functions:
driver/driver - Construct database driver object.
driver/get - Get database driver properties.
driver/isdriver - Detect if driver is a valid JDBC driver object.
driver/isjdbc - Detect if driver is JDBC-compliant.
driver/isurl - Detect if database URL is valid.
driver/register - Load database driver.
driver/unregister - Unload database driver.
Database Toolbox Drivermanager functions:
drivermanager/drivermanager - Construct database drivermanager object.
drivermanager/get - Get database drivermanager properties.
drivermanager/set - Set database drivermanager properties.
Database Toolbox Resultset functions:
resultset/clearwarnings - Clear the warnings for the resultset.
resultset/close - Close resultset object.
resultset/get - Get resultset properties.
resultset/isnullcolumn - Detect if last record read in resultset was null.
resultset/namecolumn - Map resultset column name to resultset column index.
resultset/resultset - Construct resultset object.
Database Toolbox Resultset MetaData functions:
rsmd/rsmd - Construct resultset metadata object.
rsmd/get - Get resultset metadata properties.
Database Toolbox bulk insert examples:
dbdemos/mssqlserverbulkinsert - MS SQL Server bulk insert example.
dbdemos/mysqlbulkinsert - MySQL bulk insert example.
dbdemos/oraclebulkinsert - Oracle bulk insert example.
Visual Query Builder functions:
vqb/confds - Configure data source (UNIX only).
vqb/getdatasources - Return valid data sources on system.
vqb/loginconnect - Datasource connection.
vqb/parsebinary - Write binary object to disk.
vqb/qbhelp - Query Builder help string.
vqb/querybuilder - Start visual SQL query builder.
vqb/showdata - Display data in interactive window.
vqb/showdatacallbacks - Visual Query Builder data display callbacks.
vqb/vqbdemo - Visual Query Builder demonstrations.
database is both a directory and a function.
DATABASE Connect to database.
CONNECT = DATABASE(INSTANCE,USERNAME,PASSWORD,DRIVER,DATABASEURL)
returns a database connection object. INSTANCE is the name of the
database, USERNAME is the user name. PASSWORD is the password
that permits access to the database. DRIVER is a JDBC driver name and
DATABASEURL is the URL for the database. The latter arguments are
optional but both must be used in conjunction with each other.
Use LOGINTIMEOUT before DATABASE to set the maximum time for a
connection attempt.
Example:
JDBC-ODBC connection:
conn=database('oracle','scott','tiger')
where:
'oracle' is the ODBC datasource name for an ORACLE database.
'scott' is the user name.
'tiger' is the password.
JDBC connection:
conn=database('oracle','scott','tiger',
'oracle.jdbc.driver.OracleDriver','jdbc:oracle:oci7:')
where:
'oracle' is the database name.
'scott' is the user name.
'tiger' is the password.
'oracle.jdbc.driver.OracleDriver' is the JDBC driver to be used
to make the connection.
'jdbc:oracle:oci7:' is the URL as defined by the Driver vendor
to establish a connection with the database.
See also close.
JDBC的driver 例子
IBM Informix
JDBC driver: com.informix.jdbc.IfxDriver
Database URL: jdbc:informix-sqli://161.144.202.206:3000:
INFORMIXSERVER=stars
MySQL
JDBC driver: twz1.jdbc.mysql.jdbcMysqlDriver
Database URL: jdbc:z1MySQL://natasha:3306/metrics
JDBC driver: com.mysql.jdbc.Driver
Database URL: jdbc:mysql://devmetrics.mrkps.com/testing
Oracle oci7 drivers
JDBC driver: oracle.jdbc.driver.OracleDriver
Database URL: jdbc:oracle:oci7:@rex
Oracle oci8 drivers
JDBC driver: oracle.jdbc.driver.OracleDriver
Database URL: jdbc:oracle:oci8:@111.222.333.44:1521:
Database URL: jdbc:oracle:oci8:@frug
Oracle thin drivers
JDBC driver: oracle.jdbc.driver.OracleDriver
Database URL: jdbc:oracle:thin:@144.212.123.24:1822:
Oracle 10 connections with JDBC (thin drivers)
JDBC driver: oracle.jdbc.driver.OracleDriver
Database URL: jdbc:oracle:thin: (do not specify the target name and port)
In this example, the target machine on which the database server resides is 144.212.123.24 and the port number is 1822.
PostgreSQL
JDBC driver: org.postgresql.Driver
Database URL: jdbc:postgresql://masd/MOSE
PostgreSQL with SSL connection
JDBC driver: org.postgresql.Driver
Database URL: jdbc:postgresql:servername:dbname:ssl=
true&sslfactory=org.postgresql.ssl.NonValidatingFactory& (the trailing & is required)
Microsoft SQL Server
JDBC driver: com.microsoft.jdbc.sqlserver.SQLServerDriver
Database URL: jdbc:microsoft:sqlserver://localhost:port;database=databasename
Note For MS SQL Server 2005, the Driver and URL syntax has changed to:
JDBC driver: com.microsoft.sqlserver.jdbc.SQLServerDriver
Database URL: jdbc:sqlserver://localhost:port;database=databasename
Sybase SQL Server and Sybase SQL Anywhere
JDBC driver: com.sybase.jdbc.SybDriver
Database URL: jdbc:sybase:Tds:yourhostname:yourportnumber/
JDBC连接数据库的参数:
conn = database('databasename','username',...
'password','driver','databaseurl') connects a MATLAB software session to a database and assigns the returned connection object to conn. The arguments passed to this function are as follows:
databasename: The name of the database to which you connect.
driver: The name of your JDBC driver.
Note The JDBC driver is sometimes referred to as the class that implements the Sun Java SQL driver for your database.
username and password: The user name and password required to connect to the database. If a user name or password are not required to connect to your database, specify empty strings for these arguments.
Find the correct driver name
databaseurl: A JDBC URL object of the form jdbc:subprotocol:subname. subprotocol is a database type, such as Oracle. subname may contain other information used by driver, such as the location of the database and/or a port number. subname may take the form //hostname:port/databasename.
If database establishes a database connection, it returns information about the connection object, as shown in the following example:
Instance: 'SampleDB'
UserName: ''
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: []
Handle: [1x1 sun.jdbc.odbc.JdbcOdbcConnection]
TimeOut: 0
AutoCommit: 'off'
Type: 'Database Object'
2)连接mysql
a)如果是测试开发用,可以下载安装xampp
http://www.apachefriends.org/zh_cn/xampp-windows.html
b)安装JDBC驱动
http://dev.mysql.com/downloads/mirror.php?id=408558
安装mysql驱动程序包,详细步骤如下:
Step 1: 将mysql-connector-java-5.1.21-bin.jar文件拷贝到......MATLAB\R2011b\java\jar\toolbox
Step 2: 到......\MATLAB\R2009a\toolbox\local目录下,找到classpath.txt文件,打开,并添加用来加载mysql的jdbc驱动语句:
$matlabroot/java/jar/toolbox/mysql-connector-java-5.1.21-bin.jar
Step 3:重新打开MATLAB即可
c)编写代码连接
myconn=database('test','root','','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/test')
myconn =
Instance: 'test'
UserName: 'root'
Driver: 'com.mysql.jdbc.Driver'
URL: 'jdbc:mysql://localhost:3306/test'
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: []
Handle: [1x1 com.mysql.jdbc.JDBC4Connection]
TimeOut: 0
AutoCommit: 'on'
Type: 'Database Object'
>> ping(myconn)
ans =
DatabaseProductName: 'MySQL'
DatabaseProductVersion: '5.5.25a'
JDBCDriverName: 'MySQL-AB JDBC Driver'
JDBCDriverVersion: [1x60 char]
MaxDatabaseConnections: 0
CurrentUserName: 'root@localhost'
DatabaseURL: 'jdbc:mysql://localhost:3306/test'
AutoCommitTransactions: 'True'
设置连接超时时限
>> logintimeout('com.mysql.jdbc.Driver',10)
ans =
10
>>
发表评论
-
R语言与数据分析
2015-05-15 20:58 2064当今计算机系统要处理的数据类型变得多种多样,并且为了深入理 ... -
机器学习实践指南:案例应用解析
2014-04-17 19:53 1005试读及购买链接 《机器 ... -
matlab-矩阵合并
2013-06-10 13:56 3126a = 1 2 3 2 -
人工智能与数据分析所需要的知识
2013-04-30 18:27 292想较好得在数据分析和人工智能相关领域发展,最好具备以下基础: ... -
麦哈普的AI乐园【myhaspl@qq.com】我的另一个博客(机器学习、数据分析、智能计算的原创)
2013-04-28 10:52 11http://blog.csdn.net/u0102556 ... -
R-并行计算
2013-04-28 10:50 6061啊。。。找了一下,R 居然真的有办法可以多cpu平行运算!! ... -
谱聚类
2013-04-11 10:44 26641. 谱聚类 给你博客园上若干个博客,让你将它 ... -
对变化建模-用差分方程-动力系统及常数解
2013-04-09 15:24 1385差分表示在一个时间周期里考察对象的变化量。 差分表示在一个时 ... -
逻辑斯蒂映射-伪随机数
2013-04-04 15:28 3310逻辑斯蒂映射的形式为 x_(n+1)=ax_n( ... -
matlab-多项式乘除法及式子和导数
2013-03-21 15:06 4581>> a=[22 12 4 54] ... -
matlab-数组-元胞数据与结构数组
2013-03-20 17:45 3224y、z是元胞数组,num2cell完成由数值数组到元胞数组的 ... -
矩阵-范数
2013-03-13 17:30 1846>> a a = 12 33 ... -
向量-范数
2013-03-13 16:06 2266>> b=a(3,:) b = 22 ... -
矩阵-求逆
2013-02-27 15:51 2460设R是一个交换环,A是 ... -
lisp-猜数字算法与全局函数、变量
2013-01-30 17:55 1608* (defvar *big* 100) *BIG* ... -
开源 Lisp 相关项目
2013-01-19 22:38 3849IOLib 项目 (http://common-lisp.n ... -
四分位数求法
2012-11-22 20:18 2793四分位数间距:是上四分位数与下四分位数之差,用四分位数间距可反 ... -
matlab-神经网络-自定义多层感知器解决异或(2)
2012-10-10 22:33 2450继续定义单元神经元 net.inputs{i}.ran ... -
matlab-神经网络-自定义多层感知器解决异或(1)
2012-10-09 22:41 5133>> net=network net = ... -
matlab-模态对话框
2012-10-05 16:59 3481modal dialog box with the comm ...
相关推荐
matlab与sql数据库连接,实例说明,M文件
Matlab与数据库连接.rar
matlab开发-A制冷数据库连接。查询数据源并将数据插入数据源。
Matlab与数据库连接[收集].pdf
初学者可以使用的matlab链接sql数据的入门指南,对于需要的同学相信会有比较好的参考价值
Matlab与PostgreSQL数据库的连接方法,亲测可用
详细的介绍了Matlab 与数据库连接的操作,可应用于用matlab实现机器学习所需的数据库操作
Matlab建立到Oracle数据库的连接
matlab与远程数据库的连接设置,各种参数的设置,个人感觉很好的教程。
该文档详细描绘了用matlab来连接和访问mysql数据库,并附有详细代码
matlab 连接数据库以及导出数据库数据CSV格式,数据库建立、表建立、字段建立请参考 https://blog.csdn.net/weixin_37928884/article/details/128222667 公开文章,SQLServer数据库中运行程序即可。
MATLAB
MATLAB
这是利用Matlab链接数据库的代码,本人亲测有效,有需要的同学可以下载,学习运用。
Matlab数据库编程指南-Godman Matlab与数据库链接有三种方法,本文只讲述其中以ODBC的方式进行链接。 本文件包含四部分,其中第三部分为我自己写的一些数据库函数操作的函数,第四部分为网上的一些资料。 第一...
PI数据库的示例程序,包括ManageServers,modattrsvb,PI SQC Automation Example,Recalculate and Resize DataLink code example,PIDELETE_2_1e (GUI)。
matlab,Oracle,在matlab下实现数据库连接也还是很方便的!
MATLAB 2016a 数据库连接步骤
详细讲解了matlab gui的数据库编程,以一个学生成绩管理系统的实例深入分析数据库编程的方法。
介绍matlab操作数据库方法,包括怎么连接数据库怎么查询数据库,怎么导入,更新,修改,及一些常用函数