SQLServerException:用户"sa"的登录失败 [英] SQLServerException: Login failed for user 'sa'
问题描述
当我的Web应用程序尝试访问数据库并尝试连接时,出现此错误
When my web application tries to access the database and tries to connect I get this error
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:1735d097-3f1b-413e-9d33-6a7ba2fbeb65
这是我的连接字符串:
private static final String DBDriver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String DBUrl = "jdbc:sqlserver://localhost;database=Survey;";
private static final String DBUser = "sa";
private static final String DBPass = "sa123";
推荐答案
最好在您的数据库服务器中创建一个新用户,然后尝试使用该新用户访问它.
Better create a new User in your DB server and try accessing it using the new user.
使用以下代码创建新用户
Use the following code to create new user
-使用密码'340 $ Uuxwp7Mcxo7Khy'创建登录AbolrousHazem. 创建登录AbolrousHazem WITH PASSWORD ='340 $ Uuxwp7Mcxo7Khy'; 开始
-- Creates the login AbolrousHazem with password '340$Uuxwp7Mcxo7Khy'. CREATE LOGIN AbolrousHazem WITH PASSWORD = '340$Uuxwp7Mcxo7Khy'; GO
-为上面创建的登录名创建数据库用户. 为登录创建用户AbolrousHazem; 开始
-- Creates a database user for the login created above. CREATE USER AbolrousHazem FOR LOGIN AbolrousHazem; GO
这篇关于SQLServerException:用户"sa"的登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!