We use cookies. By browsing our site you agree to our use of cookies ( more on privacy ).


The Database Connector is a JDBC based connector for working with databases in MATLAB. The Database Connector is both an object-oriented MATLAB layer to JDBC drivers and a smart mechanism to transport data from the Java to the MATLAB side in a performing and controlled manner.

Code examples

First, a plain SQL based quick-start example is provided. Second, a slightly more advanced example is given in which the information from the database is being used to create the MATLAB Callable Statement object.

Note: Only in the first example the code for the database connector object creation and cleanup is shown.
The remainder of the examples assume the database object is present and will be cleaned up by the user when done.

Example 1: Getting started

% Install the mysql driver specifics once

% Create a mysql database connector object
% First argument defines the database configuration to use
% Next arguments are self explaining name-value pairs
aa = monkeyproof.database.jdbc('mysql.xml', ...
	'address', 'myserver.mydomain', ...
	'databaseName', 'mydatabase');

% Just query away
% The connector will ask for your credentials 
q = aa.query('SELECT * FROM mytable');

% Log off

% Cleanup

Example 2: Working with callable statements

% Create statement based on procName, procSchema, procCatalog
myCallStmt = aa.createCallStmt('createNewUser', 'dbo', aa.databaseName)

% Note: A unique identifier 'mydatabase.dbo.createNewUser' has been 
% generated from the location of the procedure in the database

% Show how to use the statement by generating template code

%  The code below is based on the template code above)
myNewUser = struct( ...
	'firstname', 'John', ...
	'lastname',  'Doe', ...
	'e_mail',    'john.doe@example.com', ...
	'username',  'john.doe', ...
	'status',    'Active');

% Do the actual call
result = aa.updateCallStmt('mydatabase.dbo.createNewUser', myNewUser)

Objectives & Capabilities

Bring the price-tag down

One of the two main objectives of the MonkeyProof Database Connector is to bring the cost of working with databases and MATLAB down. In many of our projects we need to interact with databases. The individual user (licensing) cost to access databases from MATLAB had to come down.

Control data type mapping

MATLAB's standard Java interface does not provide sufficient control over how database types (both standard JDBC and database specific types) are converted into MATLAB data types. The Database Connector provides full control by means of configurable data type mapping.


MATLAB's standard Java interface puts a serious constraint on the performance when transporting database data from the Java side to MATLAB. This performance needed to be improved. The MonkeyProof Database Connector provides high-performance data transfer via native memory, as well as custom Java-MATLAB, and the standard Java-MATLAB interface.

Maximum fall-back

Maximum flexibility to handle unexpected behavior and non-standard configurations of JDBC drivers is achieved by making the underlying Java objects available to the user.


A high level of configurability is required to allow for new flavors of databases to be supported. The MonkeyProof Database Connector has been tested with a variety of JDBC drivers without issues.

Callable Statements

Many of our database applications rely on server side functionality programmed in stored procedures. The MonkeyProof Database Connector contains functionality to retrieve the calling interface of the stored procedure and generate the necessary MATLAB code for you.

Prepared and Callable Statements

The object-oriented architecture architecture of the Database Connector allows for an effective caching mechanism of defined prepared- and callable-statements. On a broken connection statement Java objects are typically lost. The Database Connector however, caches the necessary information in MATLAB to allow for quick re-instantiation of the Java Statement objects.

Single Sign-On (SSO)

The Database Connector supports single sign-on for Microsoft SQL Server on Windows.

Key Features

  • Cross-platform (Windows, Linux, Mac)
  • Built on JDBC
  • Optimized for performance
  • Works with multiple database (flavors) in parallel
  • MySQL, Microsoft SQL Server, and Oracle supported
  • Other database flavors with JDBC drivers successfully tested
  • MATLAB side caching of JDBC objects
  • Retrieve data into MATLAB cells, structures, and tables
  • Supports plain SQL, prepared and callable statements
  • Supports transactions
  • Supports MS SQL Server Single Sign-On on Windows
  • Data-type mapping configurable (services available)
  • Underlying Java objects available for maximum control
  • Hooks for execution of MATLAB code on e.g. establishment of a connection
  • Create callable statement objects by procedure name
  • Generate template code for working statements


For inquiries, licensing options and pricing contact us at MonkeyProof Solutions.