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!