title: java.sql.SQLException: Login failed for user 'admin'
body: <p>Disclaimer: I have never used SQL server before.</p>
  
  <p>I am trying to connect to SQL server Express using java code.</p>
  
  <pre><code>public class Test1 {
  
      public static void main(String[] args) throws SQLException, ClassNotFoundException {
          Class.forName("net.sourceforge.jtds.jdbc.Driver");
          String url = "jdbc:jtds:sqlserver://localhost:1433/POC;instance=MOHITCH-LAPTOP/SQLEXPRESS";
          String user = "admin";
          String password = "admin";
          Connection conn = DriverManager.getConnection(url, user, password);
          Statement st = conn.createStatement ();
              ResultSet rs = st.executeQuery("select * from POC.dbo.poc_table");
              while (rs.next())
              {
                  System.out.println(rs.getInt(1) + " " + rs.getString(2));
              }
          }
      }
  </code></pre>
  
  <p><strong>And I am getting the exception:</strong>   </p>
  
  <pre><code>Exception in thread "main" java.sql.SQLException: Login failed for user 'admin'.
      at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:372)
      at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
      at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
      at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC2.&lt;init&gt;(ConnectionJDBC2.java:352)
      at net.sourceforge.jtds.jdbc.ConnectionJDBC3.&lt;init&gt;(ConnectionJDBC3.java:50)
      at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:185)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at my.java.Test1.main(Test1.java:16)
  </code></pre>
  
  <p>I also tried logging in using MS SQL server Management Studio 2014. And I <strong>successfully</strong> did it.</p>
  
  <p><img src="https://i.stack.imgur.com/w3rVC.png" alt="enter image description here"></p>
  
  <p>Here is my database structure: <br><br><img src="https://i.stack.imgur.com/E0AsZ.png" alt="enter image description here"></p>
  
  <p>Any help is highly appreciated!!<br>
  Thanks</p>