我編寫(xiě)了一個(gè)非常簡(jiǎn)單的jdbc登錄測(cè)試程序。在遇到各種問(wèn)題之后,我?guī)缀醵伎梢哉9ぷ髁?。幾乎,似乎無(wú)法擺脫此“ SQLServerException:用戶(hù)xxxxx登錄失敗”的問(wèn)題。我創(chuàng)建了一個(gè)簡(jiǎn)單的數(shù)據(jù)庫(kù)PersonInfo,然后創(chuàng)建了用戶(hù)user1 password1(sql身份驗(yàn)證)。嘗試之后,所有內(nèi)容都無(wú)法連接到數(shù)據(jù)庫(kù)。我在Win 7上使用SqlServer2008,我從Microsoft獲得了最新的jdbc驅(qū)動(dòng)程序。我的代碼是: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(); }}}這是例外Exception: Unable to get connectcom.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'Sohaib'.and all other supporting errors..不幸的是,在某種SqlServer Guru或Jdbc Guru憐憫我并幫助我之前,我現(xiàn)在已死于水中。提前致謝。
SqlServer:用戶(hù)登錄失敗
紅顏莎娜
2019-12-04 14:44:00