New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
database connection error #3
Comments
There is a work-around using the database toolbox. Another method is using a method suggested in http://stackoverflow.com/questions/24438359/connecting-matlab-and-mysql-with-the-jdbc-driver My new and working (for me) mysql_dbconnect.m looks like this function [dbconnection, errmsg] = mysql_dbopen(serverhost, dbname, uname, pword)
javaaddpath('/home/philip/work/CompEngineMatlab/Database/mysql-connector-java-5.1.34-bin.jar')
% Open database
errmsg = []; % error message
% Now try to connect
try
d = com.mysql.jdbc.Driver;
dburl = sprintf('jdbc:mysql://%s/%s', serverhost, dbname);
props = java.util.Properties;
props.put('user',uname); props.put('password',pword);
dbconnection = d.connect(dburl,props);
catch le
fprintf(1,'Error connecting to the database ''%s'' at ''%s'':\n%s\n',dbname,serverhost,le.message);
fprintf(1,['Perhaps an incorrect username (''%s'') and password (''%s'') combination?\n'], uname, pword);
dbconnection = [];
% Not really a Matlab 'error' -- just print the suspected problem to screen
end And it works like a charm. I think the problem lies with the java.lang.Class.forName('com.mysql.jdbc.Driver', true, cl) method. But that is just gut feeling |
The mysql_dbconnect.m seems to create a memory issue with java when running on multiple timeseries on my machine which results in a complete freeze of matlab. |
This is now fixed -- mysql_dbopen uses the database toolbox if a license is available, otherwise reverts to the original implementation. |
mysql_dbopen.m throws error even after including the appropriate connector via
javaaddpath('/home/philip/work/CompEngineMatlab/Database/mysql-connector-java-5.1.34-bin.jar')
The text was updated successfully, but these errors were encountered: