when i am trying to connect sql server 2008 with jdbc an exception has occured as fellows com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'.
the code is shown as follows
import java.sql.*;
public class myjdbc {
public static void main(String[] args) {
String sDriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String Name = "sa";
String Pswd = "1111";
String aDBUrl = "jdbc:sqlserver://localhost:1433;databaseName=pasdb";
//String bDBUrl = "jdbc:sqlserver://scu-PC\\Barney;databaseName=pasdb;integratedSecurity=true";
try {
Class.forName(sDriverName);
DriverManager.getConnection(aDBUrl,Name,Pswd);
//DriverManager.getConnection(bDBUrl);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
When i use the bDBUrl method to connect SQL, all goes well; when i use the aDBUrl mehtod, the error goes out.
PS: i can login sql server by using account sa through sql server management studio