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!