try {
      Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
      CachedRowSet crs = new CachedRowSetImpl();
      crs.setSyncProvider("com.fred.providers.HighAvailabilityProvider");
      crs.setUrl(
          "jdbc:microsoft:sqlserver://ldy:1433;DatabaseName=DaoGouTongDB");
      crs.setUsername("sa");
      crs.setPassword("mynameisxulong");
      crs.setCommand("select CompanyID,PersonName from guestbook");
      crs.execute();
      crs.first();
      crs.updateString("PersonName", "111111111111");
      crs.updateInt("CompanyID", 2);
      crs.updateRow();
      crs.close();
    }
    catch (Exception e) {
    }

本文转载:CSDN博客