The configuration process in Linux is the same as that in Windows. 1. Copy the JAR package of OracleJDBC to the relevant directory of Matlab (.. javajartoolbox.
The configuration process in Linux is the same as that in Windows. 1. Copy the JAR package of Oracle JDBC to the relevant directory of Matlab (.. \ matlab \ java \ jar \ toolbox.
1. Matlab establishes a connection to the Oracle database through ODBC
1. In Windows, choose Start> Control Panel> performance and maintenance> Administrative Tools and click data source (ODBC )"
2. Select "system DSN"> "add"> select "Oracle in your lient11g_home1" and click "finish ".
3. Configure the Oracle ODBC driver.
4. Click "OK.
5. Establish a JDBC connection test to Oracle in Matlab.
> Conn = database ('test', 'Scott ', '000000'); (Press enter)
2. Matlab establishes a connection to the Oracle database through JDBC
The configuration process in Linux is the same as that in Windows:
1. Copy the Oracle jdbc jar package to the relevant Matlab directory (.. \ matlab \ java \ jar \ toolbox.
In the Oracle 11g installation directory, jdbc à lib (for example, \ app \ Administrator \ product \ 11.1.0 \ client_1 \ jdbc \ lib) has four files: ojdbc5.jar, ojdbc5_g.jar, ojdbc6.jar, and ojdbc6_g.jar.
Ojdbc5.jar and ojdbc5_g.jar are used in jdk1.5 and ojdbc6.jar and ojdbc6_g.jar are used in jdk1.6. Copy ojdbc6.jar to the java \ jar \ toolbox directory in the matlab main directory.
For example:
Oracle 11g is used on the Oracle server.
Copy the ojdbc6.jar package to the D: \ matlab \ R2008b \ java \ jar \ toolbox directory.
Note:
1. The client's ojdbc6.jar exists in the. \ product \ 11.1.0 \ client_1 \ jdbc \ lib directory.
2. The ojdbc6.jar on the server exists in the directory .. \ product \ 11.1.0 \ db_1 \ jdbc \ lib.
2. Configure the classpath.txt file of MATLAB
Open the. \ matlab \ toolbox \ localdirectory and edit the classpath.txt file. Add the following lines:
$ Maid/java/jar/toolbox/ojdbc6.jar
And save.
3. Establish a JDBC connection test to Oracle in Matlab.
> Conn = database ('orcl ', 'Scott', '123 ',
'Oracle. jdbc. driver. OracleDriver ',
'Jdbc: oracle: thin: @ 192.168.0.101: 1521 :');
(Press enter)
Parameter description:
Orcl: Database Service name
Scott: User Name
123456: User Password
Oracle. jdbc. driver. OracleDriver: driver
Jdbc: oracle: thin: @ 192.168.0.101: 1521: connection string
3. Simple database operations in Matlab
1. Connection
Conn = database (), the database must be three or five input parameters
2. Execute the query
Curs = exec (conn, 'select * from emp ');
3. Get Data
Curs = fetch (curs)
4. insert
Insert (conn, table, colnames, exdata) such:
Insert (conn, 'tb _ queue_tmp ', {'t _ tm'}, {'123 '})
5. update
Update (conn, table, colnames, exdata, whereclause)