matlab won't show text while cennecting to a database
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
i have a gui that can check the connection to a mysql database. While the connection is being checked, i want to display a text simply saying 'connection check in progress...'. This text is overwritten depending whether the connection is established or not. The problem is that the gui is like frozen when you click the check-button (the connection check is in progress) and then displays the result, but 'connection check in progress...' is not displayed. The funny thing is that when you enter the gui in debug mode and do the check step by step, the texts are displayed correctly. This is also true if i add a pause before i set the text.
My question is, why the text is not displayed correctly and how i can display it without a pause (i don't want to slow down the program).
Here is an extract from my code:
if portState == 0
set(handles.storedDB,'String','Retrieving Data...');
set(handles.text10,'String',[message,' Connection check in progress... ']);
conn=database(dbName,user,password,'com.mysql.jdbc.Driver',['jdbc:mysql://',dbServerIP,':',port,'/',dbName]);
connstate = isconnection(conn);
message = [message, conn.Message];
if connstate == 1
e = exec(conn,'select user(), database();');
e = fetch(e);
g = exec(conn,'show databases');
g = fetch(g);
set(handles.storedDB,'String',g.data); %update listbox
message = [message,' USER: "',e.Data{1,1},'" on database: "', e.Data{1,2},'"'];
Basically the set handles strings are ignored when running the check.
Thanks for your help!
0 个评论
回答(1 个)
David Sanchez
2013-12-10
Add a very short pause right AFTER the set line:
...
...
set(handles.text10,'String',[message,' Connection check in progress... ']);
pause(0.001);
...
...
this doesn't slow down the application considerably, and your text will be displayed.
2 个评论
另请参阅
类别
在 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!