Win764-bit system Matlab access Mysql database (Details !)
Access Mysql database using Win7 64-bit system Matlab
PS: I have read a lot of technical posts on the Internet that use Matlab to connect to Mysql, but there are always problems with my own operations. Now I am writing a detailed technical post, hoping to avoid detours in the future! Some matlab database statements will be written later!
Instance:
I) download to get the mysql-connector-java-5.1.35-bin.jar;
Download: mysql-connector-java-gpl-5.1.35.msi (Don't worry this is 32-bit)
Run -- C: \ ProgramFiles (x86) \ MySQL Connector J -- mysql-connector-java-5.1.35-bin.jar
II) copy to the D: \ ProgramFiles \ Matlab \ R2009b \ java \ jar \ toolbox folder;
III) add a sentence to classpath.txt under path D: \ Program Files \ Matlab \ R2009b \ toolbox \ local to load the jdbc driver of mysql.
$ Matlabroot/java/jar/toolbox/mysql-connector-java-5.1.35-bin.jar, close matlab, re-open, everything OK.
Note: 1. Classpath.txt directly add $ MATLAB root/java/jar/toolbox/mysql-connector-java-5.1.35-bin.jar. Do not add above #
2. mysql-connector-java-5.1.35-bin.jar version to be consistent 3. conn = database ('test', 'root', '123', 'com. mysql. jdbc. driver ', 'jdbc: mysql: // 127.0.0.1: 3306/test') conn = Instance: 'imgtograph' UserName: 'root' Driver: [] URL: [] Constructor: [1x1 com. mathworks. toolbox. database. databaseConnect] Message: 'unable to find JDBC driver. 'handle: 0 TimeOut: 0 AutoCommit: 'off'
Type: 'database Object'
Error: 'unable to find JDBC driver .'
Solution: 1. test must be the database name, not the connection name (when you find that the mysql-connector-java-5.1.35-bin.jar replication and classpath.txt are correct, check if your statement has a problem !)
2. Restart matlab
conn=database('123','root','123456','com.mysql.jdbc.Driver','jdbc:mysql://127.0.0.1:3306/123')conn =Instance: '123'UserName: 'root'Driver: 'com.mysql.jdbc.Driver'URL: 'jdbc:mysql://127.0.0.1:3306/123'Constructor: [1x1com.mathworks.toolbox.database.databaseConnect]Message: []Handle: [1x1com.mysql.jdbc.JDBC4Connection]TimeOut: 0AutoCommit: 'on'Type: 'Database Object'
Successful!