블로그 이미지
다엄
잘해야지

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Notice

    'Programming/Java'에 해당되는 글 10

    1. 2010.06.22 자바 ResultSet
    2010. 6. 22. 12:01 Programming/Java

    출처 : http://java.sun.com/j2se/1.5.0/docs/api/java/sql/ResultSet.html

    Statement stmt = con.createStatement(
                                          ResultSet.TYPE_SCROLL_INSENSITIVE,
                                          ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
    // rs will be scrollable, will not show changes made by others,
    // and will be updatable

    1. to update a column value in the current row. In a scrollable ResultSet object, the cursor can be moved backwards and forwards, to an absolute position, or to a position relative to the current row. The following code fragment updates the NAME column in the fifth row of the ResultSet object rs and then uses the method updateRow to update the data source table from which rs was derived.

             rs.absolute(5); // moves the cursor to the fifth row of rs
             rs.updateString("NAME", "AINSWORTH"); // updates the 
                // NAME column of row 5 to be AINSWORTH
             rs.updateRow(); // updates the row in the data source
      
       
    2. to insert column values into the insert row. An updatable ResultSet object has a special row associated with it that serves as a staging area for building a row to be inserted. The following code fragment moves the cursor to the insert row, builds a three-column row, and inserts it into rs and into the data source table using the method insertRow.
             rs.moveToInsertRow(); // moves cursor to the insert row
             rs.updateString(1, "AINSWORTH"); // updates the 
                // first column of the insert row to be AINSWORTH
             rs.updateInt(2,35); // updates the second column to be 35
             rs.updateBoolean(3, true); // updates the third column to true
             rs.insertRow();
             rs.moveToCurrentRow();
      
    posted by 다엄
    prev 1 2 3 4 5 6 7 ··· 10 next