Can only connect to master database with JDBC Sql Server

故事扮演 提交于 2021-01-29 08:02:17

问题


I just successfully connected my android app with a database running on azure cloud services to run simple queries.

The connection string provided by azure already specifies which database I want to connect to, but when it is trying to execute a select query in that database the table cannot be found because the query is being executed on Master database.

jdbc:jtds:sqlserver://{servername}:1433;database=BDassistance;user={username};password={password};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;";

BDassistance is the database I want to connect to and run queries, but its tables cannot be found and when running

SELECT DB_NAME()

it returns "Master".

What is going on here? Did I forget a parameter in my connection?

来源:https://stackoverflow.com/questions/53070013/can-only-connect-to-master-database-with-jdbc-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!