How can I get a GUI connecting to MATLAB via a button
Show older comments
Hi, I am new to MATLAB and the whole world of programming so please excuse me for basic ignorance. I have a MySQL database setup and have managed to connect to it via the command line on MATLAB using this code:
dbname ='TestPLS-DAscema';
username = 'root';
password = 'password';
driver = 'com.mysql.jbdc.Driver';
uburl = ['jbdc:mysql://localhost:3306/' dbname];
javaclasspath('/home/gurvinder/Downloads/mysql-connector-java-5.1.25/mysql-connector-java-5.1.25-bin.jar');
conn = database(dbname, username, password, driver, uburl);
I have created a basic GUI with a button so that when i click on it, it will connect to the database.
I thought it would be as simple as putting the above code under the function caller so that when it clicks on the button it excutes the code giving me something like this:
function pushbutton1_Callback(hObject, eventdata, handles)
dbname ='TestPLS-DAscema';
username = 'root';
password = 'password';
driver = 'com.mysql.jbdc.Driver';
uburl = ['jbdc:mysql://localhost:3306/' dbname];
javaclasspath('/home/gurvinder/Downloads/mysql-connector-java-5.1.25/mysql-connector-java-5.1.25-bin.jar');
conn = database(dbname, username, password, driver, uburl);
But this does not seem to be working, as when i type "ping(conn)" into the command line an error is returned "database.ping at 153 invalid connection" and isconnection returns with a 0.
Like i said i am a complete noob at this and was hoping someone could point me into the correct direction to allow a simple button on a GUI to connect to a database.
Accepted Answer
More Answers (0)
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!