检查一下你的连接sql中是否有错
  //连接数据库
  public static synchronized Connection getConnection() throws Exception{
    try{
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
      String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydata";
      String user = "sa";
      String password = "";
      return conn=DriverManager.getConnection(url, user, password);
    }
    catch(Exception e){
      System.out.println("数据库连接错误!");
      throw e;
    }
  }