Cancelling Updates to an Updatable Result Set : ResultSet Updatable « Database « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » Database » ResultSet Updatable 
20.12.9.Cancelling Updates to an Updatable Result Set
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {
  public static void main(String[] argvthrows Exception {
    String driverName = "com.jnetdirect.jsql.JSQLDriver";
    Class.forName(driverName);

    String serverName = "127.0.0.1";
    String portNumber = "1433";
    String mydatabase = serverName + ":" + portNumber;
    String url = "jdbc:JSQLConnect://" + mydatabase;
    String username = "username";
    String password = "password";

    Connection connection = DriverManager.getConnection(url, username, password);
    Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
        ResultSet.CONCUR_UPDATABLE);
    ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table");

    // Move cursor to the row to update
    resultSet.first();

    // Update the value of column col_string on that row
    resultSet.updateString("col_string""new data");

    // Discard the update to the row
    resultSet.cancelRowUpdates();

  }
}
20.12.ResultSet Updatable
20.12.1.Determine if a Database Supports Updatable ResultSets
20.12.2.Create an Updatable ResultSet
20.12.3.Determine if a ResultSet is Updatable
20.12.4.Update a Row in a Database Table Using an Updatable Result Set
20.12.5.Cancel Updates to an Updatable ResultSet
20.12.6.Insert a Row into a Database Table Using an Updatable ResultSet
20.12.7.Delete a Row from a Database Table Using an Updatable ResultSet
20.12.8.Refresh a Row in an Updatable ResultSet
20.12.9.Cancelling Updates to an Updatable Result Set
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.