The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.sql  [73 examples] > Inserting and Updating Data  [4 examples]

e261. Updating a Row in a Database Table

This example updates a row in a table.
    try {
        Statement stmt = connection.createStatement();
    
        // Prepare a statement to update a record
        String sql = "UPDATE my_table SET col_string='a new string' WHERE col_string = 'a string'";
    
        // Execute the insert statement
        int updateCount = stmt.executeUpdate(sql);
        // updateCount contains the number of updated rows
    } catch (SQLException e) {
    }

 Related Examples
e258. Inserting a Row into a Database Table
e259. Inserting a Row into a Database Table Using a Prepared Statement
e260. Getting and Inserting Binary Data into an Database Table

See also: Batching    Connections    Database Meta Data    Deleting Data    Drivers    Importing and Exporting    Oracle OBJECTs    Oracle VARRAYs    Procedures and Functions    Retrieving Data    Scrollable Result Sets    Tables    Updatable Result Sets   


© 2002 Addison-Wesley.