--以下代码我调试通过
import java.sql.*;import javax.sql.*;public class test{  public test(){} public static void main(String args[]) {   try   {     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");      Connection conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=;DatabaseName=master");     Statement stmt=conn.createStatement();      String sql="select * from userinfo";      ResultSet rs = stmt.executeQuery(sql);     while(rs.next())      {         System.out.println("username:"+rs.getString("username")+"password"+rs.getString("password"));     }   rs.close();   stmt.close();   conn.close();   }   catch(Exception ex) { System.err.println(ex.getMessage()); } } }