java的Statement的另一種更新方式 不指定

Else , 2007/11/09 17:16 , 代码片段,演示也有 , Comments(0) , Reads(1394) , Via Original
  
基礎是個好東西
或許也叫一句,即便不懂,也要看!

public int UpdateUser(String[] userinfoArray){
    int result= 0;
    SetupSQL();
    try{
      Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                          ResultSet.CONCUR_UPDATABLE);
      String sql = "select * from usertable where userid = "+userinfoArray[0];
      ResultSet rs = stmt.executeQuery(sql);
      if (rs.next())
      {
        for (int i=1;i<4;i++){
          rs.updateString(i, userinfoArray[i]);
        }
        rs.updateRow();
        result = 1;
      }
      
    }
catch(Exception ex){
      ex.printStackTrace();
    }
    
    return result;
    
  }
  
}

這個地方,以前看到的代碼是沒有見到!不明白他的工作原理
於是去找了資料
http://www.cuku.net/api/java/sql/ResultSet.html#CONCUR_UPDATABLE
Tags:
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]