从Java程序使用jdbc连接到sqldatabase时出错 [英] error connecting to sqldatabase using jdbc from a java program
问题描述
我有一个使用jdbc连接到sql中的数据库的程序.我已经使用ssms连接到数据库,没有问题,我试图在java的连接字符串中使用同一用户.
I have a program that uses jdbc to connect to a database in sql. I have connected to the database using ssms with no problem I am trying to use the same user in the connection string on java.
这是字符串 jdbc:sqlserver://tafdbserver.database.windows.net:1433;数据库= invest;用户= tfearn7879;密码= 566412Mose; encrypt = true; trustServerCertificate = false; hostNameInCertificate = *.database.windows.net; loginTimeout = 30
Here is the string jdbc:sqlserver://tafdbserver.database.windows.net:1433;database=invest;user=tfearn7879;password=566412Mose;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30
返回的错误是
我觉得奇怪的是,该用户名被列为"
I find it odd that the userid is listed as ''
我打开了数据库登录功能,并且由于登录失败而显示尝试登录,因此SQL实际上不允许登录.
I turned on logging in the database and the attempted login shows up as login failed, so SQL is in fact not allowing the logon.
我只是不确定下一步该怎么做.
I am just not sure what to do next.
推荐答案
java程序是否在安装了SSMS的同一主机上运行?如果不是,则可能需要创建防火墙规则以允许来自Java主机的流量.如果您还没有...
Is the java program running on the same host where SSMS is installed? If it is not you will likely need to create a firewall rule to allow traffic from the java host. If you haven't already...
这篇关于从Java程序使用jdbc连接到sqldatabase时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!