ResultSet: updateString(String columnName, String x) : ResultSet : java.sql : Java by API examples (example source code) Organized by topic

Java by API
C++
PHP
Java by API Home »  java.sql   » [  ResultSet  ]   
 



ResultSet: updateString(String columnName, String x)

/* 
 * */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;

public class Main {
  public static void main(String[] argsthrows Exception {
    Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
        ResultSet.CONCUR_UPDATABLE);

    String sqlQuery = "SELECT uid, name, duration from EVENTS";

    ResultSet rs = stmt.executeQuery(sqlQuery);

    while (rs.next()) {
      rs.updateString("Name""new Name");

      rs.updateRow();
    }

    rs.first();
    while (rs.next()) {
      String name = rs.getString(2);
      Timestamp hireDate = rs.getTimestamp(5);
      System.out.println("Name: " + name + " Hire Date: " + hireDate);
    }

    rs.close();

  }

  static Connection conn;

  static Statement st;

  static {
    try {
      // Step 1: Load the JDBC driver.
      Class.forName("org.hsqldb.jdbcDriver");
      System.out.println("Driver Loaded.");
      // Step 2: Establish the connection to the database.
      String url = "jdbc:hsqldb:data/tutorial";

      conn = DriverManager.getConnection(url, "sa""");
      System.out.println("Got Connection.");

      st = conn.createStatement();

    catch (Exception e) {
      System.err.println("Got an exception! ");
      e.printStackTrace();
      System.exit(0);
    }
  }
}

           
       
Related examples in the same category
1.  ResultSet.CONCUR_UPDATABLE
2.  ResultSet.TYPE_SCROLL_SENSITIVE
3.  ResultSet: absolute(int row)
4.  ResultSet: close()
5.  ResultSet: deleteRow()
6.  ResultSet.getAsciiStream(int columnIndex)
7.  ResultSet: getBlob(String colName)
8.  ResultSet: getConcurrency()
9.  ResultSet: getInt(String columnName)
10.  ResultSet: getRow()
11.  ResultSet: getString(int columnIndex)Has Download File
12.  ResultSet: getTimestamp(int columnIndex)
13.  ResultSet: getType()
14.  ResultSet: insertRow()
15.  ResultSet: isFirst()
16.  ResultSet: last()
17.  ResultSet: moveToInsertRow()
18.  ResultSet: next()
19.  ResultSet: previous()
20.  ResultSet: relative(int rows)
21.  ResultSet: updateRow()
22.  ResultSet: updateDouble(int columnIndex, double x)
23.  ResultSet: wasNull()
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.