I created a pretty straightforward JDBC login test program. And after a variety of issues, I'm almost there. Nearly, but I just can't seem to move beyond this issue:
SQLServerException: Login failed for user xxxxx
I made a basic database called PersonInfo, then I made user user1 and password1 (SQL authentication). Despite my best efforts, I was unable to establish a connection to the database. I have the most recent Microsoft JDBC driver and I'm running SQL Server 2008 on Windows 7.
My code is:
import java.sql.*;
public class hell {
public static void main(String[] args) {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
Connection conn= DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=PersonInfo;user=Sohaib;password=0000;");
System.out.println("connected");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
Here's the Exception:
Exception: Unable to get connect
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'Sohaib'.
and all other supporting errors.