(JDBC)SQL Server连接字符串:用户“"登录失败 [英] (JDBC) SQL Server connection string: login failed for user ' '
问题描述
jdbc:sqlserver://localhost:1433;数据源=(本地);最初的 Catalog = MarketDataDB;用户ID = andrew; 密码= mypassword;
jdbc:sqlserver://localhost:1433;Data Source=(local); Initial Catalog=MarketDataDB; User Id=andrew; Password=mypassword;
上面是我用于使用JDBC连接到SQL Server 2008 R2 Express数据库的连接字符串,但是会产生此错误:
Above is the connection string I am using to connect to a SQL Server 2008 R2 Express database using JDBC, but this error is produced:
用户''
有什么想法吗?
我可以使用指定的用户名和密码从SQL Server Management Studio中成功连接到数据库.我正在使用 SQL Server身份验证
I can successfully connect to the database from within SQL Server Management Studio using the specified username and password. I am using SQL Server authentication
推荐答案
1433是SQL Server(而不是SQLExpress)的默认端口.默认情况下,SQLExpress使用动态分配的端口号.您可以使用Configuration Manager小程序来检查或更改它.
1433 is the default port for SQL Server, not for SQLExpress. By default, SQLExpress uses a dynamically assigned port number. You can check this or change this using the Configuration Manager applet.
我确信您知道SQLExpress的默认安装根本不会启用TCP/IP.应用程序可以使用共享内存"协议连接到SQLExpress(当然,只能从同一台计算机上).要使用TCP/IP,必须在配置管理器中启用它.启用TCP/IP后,必须停止并重新启动SQLExpress才能使新设置生效.
I am sure you realize that a default installation of SQLExpress does not enable TCP/IP at all. Applications can connect to SQLExpress using the Shared Memory protocol (only from the same machine, of course). To use TCP/IP you must enable it in the Configuration Manager. After enabling TCP/IP you must stop and restart SQLExpress for the new setting to take effect.
这篇关于(JDBC)SQL Server连接字符串:用户“"登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!