Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 911
JoaoFilipeClementeMartins Avatar asked Nov 26 '16 15:11

JoaoFilipeClementeMartins


People also ask

WHAT IS instance name in connection string?

The Named Instance connection string is expressed as follows. Data Source= ServerName\InstanceName;Initial Catalog=DatabaseName; Authentication=Active Directory Integrated.

What is instance in jdbc?

JDBC URL ExplanationinstanceName is the database instance to connect to. If not specified, a connection to the default instance is made. portNumber is the port number of the database instance. The default is 1433. Property is one or more option connection properties.

What is the jdbc connection string for SQL Server?

jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]] where: jdbc:sqlserver:// (Required) is known as the subprotocol and is constant. serverName (Optional) is the address of the server to connect to.

What is the correct format of jdbc URL?

CFS will construct the Oracle JDBC Connection URL as jdbc:oracle:thin:@<Host Name>:<Port Number>:<Instance Name> using the values from the input fields. In summary, CFS only supports Oracle JDBC thin connection URL syntax using SID jdbc:oracle:thin:@<HOST>:<port>:<SID>.


1 Answers

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

jdbc:sqlserver://INNOWAVE-99\SQLEXPRESS01;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.

like image 68
Gord Thompson Avatar answered Sep 30 '22 23:09

Gord Thompson