![](/img/trans.png)
[英]jcifs.smb.NtlmPasswordAuthentication getPassword() null
[英]jcifs/smb/NtlmPasswordAuthentication error while connecting to SQL Server with JDBC
我正在嘗試使用JDBC
連接到MSSQL數據庫並出現以下錯誤:
jcifs/smb/NtlmPasswordAuthentication
這是我的連接字符串:
jdbc:jtds:sqlserver:/< host_name>/< db_name>;instance=< instance_name>;namedPipe=true
也嘗試了這個:
jdbc:jtds:sqlserver:/< host_name.domain_name>/< db_name>;instance=< instance_name>;namedPipe=true
每次都遇到相同的錯誤。 我可能會收到此錯誤的任何特殊原因。
我正在使用JDDS(net.sourceforge.jtds.jdbc.Driver)
驅動程序,並且該實例已配置為在動態端口上運行。
直接來自http://technet.microsoft.com/zh-cn/library/ms378428%28v=sql.110%29.aspx
jdbc:sqlserver:// (Required) is known as the sub-protocol and is constant.
serverName (Optional) is the address of the server to connect to. This could be a DNS or IP address, or it could be localhost or 127.0.0.1 for the local computer. If not specified in the connection URL, the server name must be specified in the properties collection.
instanceName (Optional) is the instance to connect to on serverName. If not specified, a connection to the default instance is made.
portNumber (Optional) is the port to connect to on serverName. The default is 1433. If you are using the default, you do not have to specify the port, nor its preceding ':', in the URL.
使用用戶名和密碼連接到本地計算機上的默認數據庫:
jdbc:sqlserver://localhost;user=MyUserName;password=*****;
要使用端口號,請執行以下操作(命名實例和多個實例)
jdbc:sqlserver://localhost:1433;integratedSecurity=true;<more properties as required>;
要使用JDBC URL屬性,請執行以下操作(命名實例和多個實例)
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;
通過使用集成身份驗證連接到本地計算機上的默認數據庫:
jdbc:sqlserver://localhost;integratedSecurity=true;
連接到遠程服務器上的命名數據庫:
jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;
在默認端口上連接到遠程服務器:
jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedSecurity=true;
通過指定自定義的應用程序名稱進行連接:
jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;applicationName=MyApp;
要使用端口號,請執行以下操作:
jdbc:sqlserver://localhost:1433;integratedSecurity=true;<more properties as required>;
要使用JDBC URL屬性,請執行以下操作:
jdbc:sqlserver://localhost;instanceName=instance1;integratedSecurity=true;<more properties as required>;
使用serverName屬性(IPV6)
jdbc:sqlserver://;serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance1;integratedSecurity=true;
使用屬性集合(IPV6)
Properties pro = new Properties();
pro.setProperty("serverName", "serverName=3ffe:8311:eeee:f70f:0:5eae:10.203.31.9\\instance1");
Connection con = DriverManager.getConnection("jdbc:sqlserver://;integratedSecurity=true;", pro);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.