MySQL and Matlab

I want to interact with a MySQL database from Matlab.
I found the mysql library "for matlab here and the same on mathworks .

I followed the instructions to compile the library, and the compilation seems successful. I get the mex32 file at the end. Only the instructions on the first page apply to the Dll that I need to use (I think that the Dll should have been generated).

I am not familiar with the mex compiler or compiling external modules for Matlab.
Am I missing something trivial? Where should the dll be?

Thanks.

+4
source share
3 answers

Link to dll is out of date.

When you compile the mex function on Windows, you compile it as a dll (not .exe). Thus, the compiled mex functions are used to extend the .dll. Mex functions with .dll extensions still work, but there is a warning that this may stop in the future.

When 64-bit Windows arrived, TheMathWorks needed people to be able to compile the same mex function for Win32 and Win64, so they changed the extension to .mexw32 and .mexw64, respectively. They apparently did not completely update the documentation.

+4
source

I would recommend using java to connect MATLAB and MySQL (or any other db if required).

The java database connector is easy to configure. I built a simple java class to connect to the database - see the previous post for a rough but working solution.

MATLAB code works as directed

 % include java class import Jam.ConnectToDatabase % set up database connection info userName='myName'; userPassword='myPassword'; databaseUrl='jdbc:mysql://glnd2818898.internal.net/2000'; % create java class instance and open connection to the database ctd = ConnectToDatabase; ctd.openConnection(userName, userPassword, databaseUrl) 

Once the connection is open, I can use java methods to send SQL queries, create tables, insert data, etc. I had never used java before, but I downloaded Netbeans and I was gone.

+4
source

OK, here is the solution to my problem.
Compiling does create a mex32 file (32 is because I compiled it on a 32-bit system). You can check the compilation output file by running mexext . Apparently, the mex32 file is a compiled version of the C file.
As soon as I put the file in a directory that is in the Matlab path, it worked.

I assume that the link to the Dll in the link provided to me is either outdated or incorrect.

0
source

Source: https://habr.com/ru/post/1304569/


All Articles