meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| applications:connect_matlab_mac [2022/05/26 21:12] – gregbalco | applications:connect_matlab_mac [2022/05/26 22:24] (current) – gregbalco | ||
|---|---|---|---|
| Line 13: | Line 13: | ||
| The first step here is to install the MATLAB ' | The first step here is to install the MATLAB ' | ||
| - | The second step is to locate and open the MATLAB help documentation for the database toolbox. This is also available online at mathworks.com. This will include instructions for how to install a 'JDBC driver' | + | The second step is to locate and open the MATLAB help documentation for the database toolbox. This is also available online at mathworks.com. This will include instructions for how to install a 'JDBC driver' |
| - | Once you have downloaded the JDBC driver (a ' | + | Once you have downloaded the JDBC driver (once it is unzipped/ |
| == Setting up SSH tunnel == | == Setting up SSH tunnel == | ||
| Line 21: | Line 21: | ||
| Unlike other GUI MySQL clients, the setup dialog in the MATLAB ' | Unlike other GUI MySQL clients, the setup dialog in the MATLAB ' | ||
| - | -- The ICE-D MySQL server is located at 123.456.789.10 (this is a made-up address, not the real one) | + | * The ICE-D MySQL server is located at 123.456.789.10 (this is a made-up address, not the real one) |
| - | -- The SSH tunnel host has the domain name ssh.tunnel.host.org (also made-up, not the real one) | + | |
| - | -- your login to the SSH tunnel host is ' | + | |
| Then issue the following command in a terminal window: | Then issue the following command in a terminal window: | ||
| Line 29: | Line 29: | ||
| '' | '' | ||
| - | What this does is forward | + | What this does is connect |
| - | Note that this won't work because the SSH host and database IP address don't exist. You'll need to put in the correct values. If you have already been using a different MySQL client, you know what these are. If not, ask Greg or Joe. | + | The port number 12345 is (obviously) arbitrary. You can use anything that is not already |
| - | One additional item of importance is that when you are done with this, you will have to shut down the SSH process that is keeping the tunnel open. Even if you do nothing, it will eventually die next time your computer goes to sleep, but it is bad practice to leave zombie processes all over the place. | + | Note that this won't work as I have written it here because the SSH host and database IP address don't exist. You'll need to put in the correct values. If you have already been using a different MySQL client, you know what these are. If not, ask Greg or Joe. |
| + | |||
| + | One additional item of importance is that when you are done with this, you will have to shut down the SSH process that is keeping the tunnel open. If you don't, it will eventually die next time your computer goes to sleep, but it is bad practice to leave zombie processes all over the place. | ||
| '' | '' | ||
| Line 39: | Line 41: | ||
| This will generate a bunch of information that will look something like this: | This will generate a bunch of information that will look something like this: | ||
| - | '' | + | < |
| - | balcs | + | balcs |
| + | balcs | ||
| + | </ | ||
| The second line tells you that the SSH process is process 7652 (everything that is running on a *nix system has its own process number). You can shut it down by typing: | The second line tells you that the SSH process is process 7652 (everything that is running on a *nix system has its own process number). You can shut it down by typing: | ||
| Line 50: | Line 54: | ||
| == Connecting MATLAB to the database through the SSH tunnel == | == Connecting MATLAB to the database through the SSH tunnel == | ||
| - | Now that you have an ssh tunnel open to the database, you need to point MATLAB to it. On current MATLAB, it appears the easiest way to do this is to use the 'JDBC data source configuration' | + | Now that you have an ssh tunnel open to the database, you need to point MATLAB to it. On current MATLAB, it appears the easiest way to do this is to use the 'JDBC data source configuration' |
| {{: | {{: | ||
| Line 62: | Line 66: | ||
| '' | '' | ||
| - | This should return a bunch of information about the database connection. You now have a live connection to the database that can be accessed | + | This should return a bunch of information about the database connection. You now have a live connection to the database that can be accessed |
| - | '' | + | '' |
| This should return: | This should return: | ||
| - | '' | + | < |
| + | query_result | ||
| 1×3 table | 1×3 table | ||
| Line 77: | Line 82: | ||
| {' | {' | ||
| - | '' | + | </ |
| What you have just done is send an SQL command to the database and obtain a result as a MATLAB variable that you can now work with in MATLAB. | What you have just done is send an SQL command to the database and obtain a result as a MATLAB variable that you can now work with in MATLAB. | ||
| Line 85: | Line 90: | ||
| '' | '' | ||
| - | To learn more about this, look at the MATLAB documentation for the commands ' | + | If everything is working as intended, the ' |
| + | |||
| + | To learn more about this, look at the MATLAB documentation for the commands ' | ||