Connection to Sql Server by JAVA - Windows Authentication

2

I want to connect to Sql Server using Java with Windows Authentication but I get the following error: This driver is not configured for integrated authentication. ClientConnectionId: 0b65956b-a286-4aef-a372-ab741a239761

This is the code I use:

public Connection getConectar(){
        Connection cn=null;
        try {
            Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            cn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=VENTAS2017;integratedSecurity=true");
            System.out.println("Conexion Exitosa");
        } 
        catch (Exception e) {
            //e.printStackTrace();
            System.out.println("ERROR"+e.getMessage());
        }
        return cn;
    }
    
asked by Bruno 09.02.2017 в 20:20
source

1 answer

2

The official documentation says:

  

The JDBC driver supports the use of integrated authentication of   type 2 on Windows operating systems through the ownership of   connection string integratedSecurity . To use the   Integrated authentication, copy the file sqljdbc_auth.dll into a   directory in the Windows system path, right where it is   installed the JDBC driver.

     

sqljdbc_auth.dll files are installed in the location   next:

<Directorio de instalación>\sqljdbc_<versión>\<idioma>\auth\

In this route you can download the driver where it comes from the DLL.

The full official documentation can be found at this link .

    
answered by 09.02.2017 / 22:32
source