matlab won't show text while cennecting to a database

1 view (last 30 days)
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!

Answers (1)

David Sanchez
David Sanchez on 10 Dec 2013
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!