Creating an Updatable Result Set : ResultSet Updatable « Database SQL JDBC « Java






Creating 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[] argv) throws 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);
    // Create a statement that will return updatable result sets
    Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

    // Primary key must be specified so that the result set is updatable
    ResultSet resultSet = stmt.executeQuery("SELECT col_string FROM my_table");

  }
}

   
    
  








Related examples in the same category

1.If database support updatable result sets
2.Using UpdatableResultSet to insert a new row
3.Delete Row from Updatable ResultSet for MySQL
4.Insert Row to Updatable ResultSet from MySQL
5.Make updates in Updatable ResultSet
6.Demo Updatable ResultSet
7.Updatable resultset with Oracle Driver
8.Determining If a Database Supports Updatable Result Sets: An updatable result set allows modification to data in a table through the result set.
9.Determining If a Result Set Is Updatable
10.Updating a Row in a Database Table Using an Updatable Result Set
11.Cancelling Updates to an Updatable Result Set
12.Inserting a Row into a Database Table Using an Updatable Result Set
13.Deleting a Row from a Database Table Using an Updatable Result Set
14.Refreshing a Row in an Updatable Result Set