Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

sql server - JDBC connection string with instance name and domain

I have a database created in SQL Server with the following configuration:

Also, I am trying to connect to the database named EDS.

For that I created the following details:

Should i have domain in the string or should it be in the username? When i go to the database properties i see the owner has. Also, is the url correct on the instance part according to the image? it looks like it is not able to go to that particular instance.

Also, this is the configuration for the connection (using Windows Authenticaton)

When I put in the username I am getting the following error log:

com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user '. ClientConnectionId:e812971f-b03c-4210-9dbd-de0791bcc304

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When specifying the location of the SQL Server instance, one normally provides serverNameinstanceName or serverName:portNumber, not both. That is, either

jdbc:sqlserver://INNOWAVE-99SQLEXPRESS01;databaseName=EDS

or

jdbc:sqlserver://localhost:1433;databaseName=EDS

(assuming that the SQLEXPRESS01 instance has been explicitly configured to listen on port 1433, which is not usually the case for a SQL Express instance).

As mentioned in the documentation for Building the Connection URL

If both a portNumber and instanceName are used, the portNumber will take precedence and the instanceName will be ignored.

There is no domain= property defined for the connection URL for Microsoft's JDBC driver for SQL Server. Logging in to the SQL Server instance with Windows domain credentials is done implicitly using the integratedSecurity=true connection property (and not explicitly providing a username and password); details here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...