You can see some other blogs here or here for the code but one thing that hasn't been pointed out clearly enough is how bad the error reporting is.
Take this, for example:
driver = 'com.mysql.jdbc.Driver';
driver = which('mysql-connector-java-5.0.8-bin.jar');
host = 'loclhost';
port = 3306;
dbname = 'MyTestDb';
user = 'tester';
password = 'god'; %The Plague wouldn't like this...
url = ['jdbc:mysql://' host ':' num2str(port) '/' dbname];
db = database(dbname, user, password, driver, url)
Looks ok, but returns the error JDBC Driver Error: com.mysql.jdbc.Driver. Driver Not Found/Loaded. Which of course would send any normal person off on a wild goose chase -- Is the jar file corrupted? Is there supposed to be a 64-bit version? Maybe I should use the fixed java class path instead of the dynamic one?
But it's just a stupid typo: 'loclhost' instead of 'localhost'. Most stupid connection string mistakes you can make (user names, port numbers, etc) will result in the same missing driver error.