필터 지우기
필터 지우기

matlab won't show text while cennecting to a database

조회 수: 1 (최근 30일)
Manuel Olschner
Manuel Olschner 2013년 12월 10일
댓글: Friedrich 2013년 12월 10일
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!

답변 (1개)

David Sanchez
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
Manuel Olschner
Manuel Olschner 2013년 12월 10일
Do you know if it's possible without a pause? But thanks.
Friedrich
Friedrich 2013년 12월 10일
You can add a drawnow instead of a pause.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by