JDBC connection string with instance name and domain

后端 未结 2 1152
日久生厌
日久生厌 2020-12-20 16:15

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 cre

相关标签:
2条回答
  • 2020-12-20 16:52

    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.

    0 讨论(0)
  • 2020-12-20 17:08

    I'm also having the same problem. Working for me too without port number. Don't forget to give semicolon at the end of the connection.

    Connect to the default database on the local computer by using integrated authentication:

    jdbc:sqlserver://localhost;integratedSecurity=true;
    

    Connect to a named database on a remote server:

    jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;
    

    Connect on the default port to the remote server:

    jdbc:sqlserver://localhost:1433;databaseName=AdventureWorks;integratedSecurity=true;
    

    Connect by specifying a customized application name:

    jdbc:sqlserver://localhost;databaseName=AdventureWorks;integratedSecurity=true;applicationName=MyApp;
    

    Reference Link : mssql document

    0 讨论(0)
提交回复
热议问题