How can I get a GUI connecting to MATLAB via a button
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Lokesh Ravindranathan
2013-7-15
Maybe a good place to start would be to use dexplore (<http://www.mathworks.com/help/database/ug/dexplore.html)>. This is the GUI interface for connecting to database. If you still have problems, contact MathWorks technical support.
2 个评论
Lokesh Ravindranathan
2013-7-17
Yes, dexplore is a relatively new function. Its available started R2012b. You should be able to use querybuilder instead.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!