title: Connect to sql server windows authentication
body: <p>I have a sql server instance , </p>
  
  <p>I can connect with sql autehntication</p>
  
  <pre><code>public static void main(String[] args) {
       Connection conn = null;
       String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
       String url = "jdbc:sqlserver://localhost:1434;databasename=Test;";
       String userName = "sa"; 
       String password = "paquito";
       Statement stmt;
       try{
         Class.forName(driver);//.newInstance();
         conn = DriverManager.getConnection(url,userName,password);
         stmt = conn.createStatement();
         System.out.println("conectado = "); 
         conn.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
  }
  </code></pre>
  
  <p>but with windows authentication</p>
  
  <pre><code>public static void main(String[] args) {
       Connection conn = null;
       String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
       String url = "jdbc:sqlserver://localhost:1434;databasename=Test;integratedSecurity=true";
       String userName = "paco"; 
       String password = "";
       Statement stmt;
       try{
         Class.forName(driver);//.newInstance();
         conn = DriverManager.getConnection(url,userName,password);
         stmt = conn.createStatement();
         System.out.println("conectado = "); 
         conn.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
  }
  </code></pre>
  
  <p>i take this error: </p>
  
  <pre><code>com.microsoft.sqlserver.jdbc.SQLServerException: Unable to open the "Test" database requested by the login. Login failed. Client connection ID: 577da72f-f0d4-4ac6-abab-243f0f84d0e3
  at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:217)
  at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:279)
  at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99)
  </code></pre>
  
  <p>NOTE: in sql management i can connect with sql authentication and windows authentication</p>
  
  <p>suggestion?</p>