JDBC Database connection through command failing.

2 次查看(过去 30 天)
Hello,
I have an issue which i dont really know how to resolve. I have connected my matlab env with a MSSQL server, using an sqlexpress db to store the data. I used a JDBC connection to link MATLAB with this database and its working fine. I have an windows authentication. When I type dexplore, open, i can configure a jdbc connection then i can see my db name, which i can access.
Now I want to make a command connection using this command line:
conn = database('dbName','','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://servername:portnumber;database=dbName;integratedSecurity=true;')
and its now working i am getting the following :
Cannot open database "GLOBALMACRO" requested by the login. The login failed. ClientConnectionId:86ac96d0-178d-48e2-80f3-a5b75a82162a.
I used the following command :
conn = database('GLOBALMACRO','','','com.microsoft.sqlserver.jdbc.SQLServerDriver','jdbc:sqlserver://TW\SQLEXPRESS:1433;database=GLOBALMACRO;integratedSecurity=true;')
Why can i access the database via the database toolkit, and cant make a connection via the above command? is there something wrong in the synthax?
I have all the rights, the sqlexpress in the studio all have TCP/IP connections equal to 1433.
Thank you very much for the help
D

采纳的回答

Davin
Davin 2014-9-2
I found a workaround issue which might help someone if ever one has the same issue, I connected to dexplore, connected to my database, I selected any table and imported the table by selecting Generating Script. And it gives you the syntax to connect to the database which is
conn = database('', '', '', 'Vendor', 'MICROSOFT SQL SERVER', 'Server', 'TW\SQLEXPRESS', 'PortNumber', 1433, 'AuthType', 'Windows');
And this works.

更多回答(0 个)

类别

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