connection to MySQL and Matlab 2010

1 次查看(过去 30 天)
hi i am trying to connect my MySQL database with matlab 2010th but I get the following error
[Microsoft] [ODBC Driver Manager] "Please verify login information and database That Are valid url."
the code I'm using is
conn=database('prueba','root','root');
if (~isconnection(conn))
str=conn.Message
h=errordlg(str,'Error','modal' );
while ishandle(h)
pause(.25)
end
error(str)
end
set(handles.Res_Des_Cas,'String',query);
prueba is my database root is my user y password
I already I have installed the MySQL ODBC 5.1 and when I use the QueryBuilder can import and export data from the database, but when I use a file .m can not

采纳的回答

Luis Osorio
Luis Osorio 2011-4-21
thank you very much but this did not work, somebody knows the code that I put in the file .m for connection

更多回答(2 个)

Oleg Komarov
Oleg Komarov 2011-4-20
You have to set up you DSN first manually:
system('%SystemRoot%\system32\odbcad32.exe');
  2 个评论
Luis Osorio
Luis Osorio 2011-4-21
thank you very much for your help, but I already set the user DNS so
Data Source Name: myqslLocal
TCP/IP Server: localhost port: 3306
user: root
password: root
Database: prueba
When I press test says connection successful. I try QueryBuilder connecting and it worked.
But I'm not sure how is the connection code that I put in matlab, or should I configure something first in matlab.
try these 2 forms and not work.
conn=database('prueba','root','root');
conn = database ('jdbc:mysql://localhost/pueba','root','root');
Walter Roberson
Walter Roberson 2011-4-21
Probably
conn = database ('jdbc:mysql://localhost:3306/pueba','root','root');

请先登录,再进行评论。


Luis Osorio
Luis Osorio 2011-4-21
thank you very much but this did not work, somebody knows the code that I put in the file .m for connection
  1 个评论
Luis Osorio
Luis Osorio 2011-4-21
thanks the code works, the code was as follows
conn = database('mysqlLocal','root','root');
if (~isconnection(conn))
str=conn.Message
h=errordlg(str,'Error','modal' );
while ishandle(h)
pause(.25)
end
error(str)
end
mysqlLocal is the name that I put to configure MySQL ODBC
I thought that was the name of the database:)

请先登录,再进行评论。

类别

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