in myeclipse , the URL used to connect to SQL Server connection with java The URL value of the code connection is exactly the same.
(The Java JDBC Connection to SQL Server successful code snippet)
1Connection conn=NULL;2 3 Try {4Class.forName ("Com.microsoft.sqlserver.jdbc.SQLServerDriver");5String url= "Jdbc:sqlserver://localhost:1433;databasename=test";6String user= "SA";//SA Super Admin7String password= "ncsd1991";//Password8 //2. Connect9conn=drivermanager.getconnection (Url,user,password);TenString sql = "SELECT *from [user]"; OnePreparedStatement s =conn.preparestatement (SQL); A //s.setstring (1, "I"); - //s.setstring (2, "1"); - //s.setstring (3, "a"); the //s.executeupdate (); -ResultSet r =s.executequery (); - while(R.next ()) { -System.out.println (r.getstring ("name")); + } -System.out.println (NULL==conn); +}Catch(Exception e) { A e.printstacktrace (); at}
Testing to connect to SQL Server in MyEclipse