matlab database

Hi, Hello, I'm trying to connect to a database using Microsoft SQL Server 2008 but i don't understand how to use the function database:
conn = database('dta_rockers','dta','dtarocks', ... 'com.microsoft.sqlserver.jdbc.SQLServerDriver', ... 'jdbc:sqlserver://kadakiak:1433;database=dta_rockers')
This is the example i find in the user's guide in order to connect with Microsoft SQL server 2005 ( and I think is right also for 2008 version). I don't have any password or user so:
>> conn=database('Mare_Taranto','','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://PAOLO-PC:fe80::c7c:6b4b:cb79:2ac3%14;database=Mare_Taranto')
PAOLO-PC is my server name, where can I find the port address of server? Do I make other mistake?
Thank you!

Respuestas (3)

Kaustubha Govind
Kaustubha Govind el 8 de Jul. de 2011

0 votos

Are you using a JDBC driver? If you do not have a username and password, it is likely that your database uses Windows authentication. See How can I access a SQL Server database with a JDBC driver if I have Windows Authentication using Database Toolbox?
You are not using the port number of the server (Not sure what fe80::c7c:6b4b:cb79:2ac3%14 is). Contact your system administrator to find the URL of your database server. If you have configured the server yourself, you should be able to find out how to figure this out by a web search. The default port number for SQL Server is 1433 I believe.
Oleg Komarov
Oleg Komarov el 8 de Jul. de 2011

0 votos

You can also use the wrapper I wrote, it should be clearer how to connect to MS SQL Server: http://www.mathworks.com/matlabcentral/fileexchange/25577-ms-sql-jdbc-connection
Paolo
Paolo el 8 de Jul. de 2011

0 votos

I changed the string with the port number but when I try to use the connection with a query:
conn = database('Mare_Taranto','','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://PAOLO-PC:1433;database=Mare_Taranto')
exec (conn, query)
tells me that the connection or is invalid or is closed. Sorry but I am just a beginner!

2 comentarios

Oleg Komarov
Oleg Komarov el 8 de Jul. de 2011
Did you follow the steps in my link? It doesn't contain just the page with my submission (which automatically handles win authentication) but it also sheds ligth on the jdbc driver and how to "install" it.
Paolo
Paolo el 10 de Jul. de 2011
I controlled your own page and I tried to install jdbc driver but the .jar file that I downloaded didn't run.
"Failed to load Main-Class manifest attribute from ..."

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 8 de Jul. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by