Receiving SQLException “Login failed for user” connecting to SQL Server 2008

后端 未结 4 1509
忘了有多久
忘了有多久 2020-12-19 06:07

I am trying to connect to SQL Server 2008 via Java.

  1. I\'ve added sqljdbc4.jar to my project\'s library.
  2. No username and password is set fo
4条回答
  •  半阙折子戏
    2020-12-19 06:25

    I was having same issue when I tried to connect to Microsoft SQL server from Java. I used jTDS driver instead of regular SQLJdbdc Driver.

            Class.forName("net.sourceforge.jtds.jdbc.Driver"); 
            String connectionUrl = "jdbc:jtds:sqlserver://localhost:1433;databaseName=DB;integratedSecurity=true";
            Connection con = DriverManager.getConnection(connectionUrl);
    

提交回复
热议问题