FileDocCategorySizeDatePackage
ExecuteIUD.javaAPI DocExample2023Tue Jun 12 21:19:14 BST 2001None

ExecuteIUD

public class ExecuteIUD extends Object

Fields Summary
Connection
conn
Constructors Summary
public ExecuteIUD()

    try {
      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
      conn = DriverManager.getConnection(
       "jdbc:oracle:thin:@dssw2k01:1521:orcl", "scott", "tiger");
    }
    catch (SQLException e) {
     System.err.println(e.getMessage());
     e.printStackTrace();
    }
  
Methods Summary
public voidexecuteIUD(java.lang.String sql)

    int       rslt = 0;
    Statement stmt = null;

    System.out.println(sql);
    try {
      stmt = conn.createStatement();
      rslt = stmt.executeUpdate(sql);
      System.out.println(Integer.toString(rslt) + " rows affected");
      System.out.println(" ");
    }
    catch (SQLException e) {
      System.err.println(e.getMessage());
    }
    finally {
      if (stmt != null) 
       try { stmt.close(); } catch (SQLException ignore) { }
    }
  
protected voidfinalize()

    if (conn != null) 
      try { conn.close(); } catch (SQLException ignore) { }
    super.finalize();
  
public static voidmain(java.lang.String[] args)

    ExecuteIUD iud = new ExecuteIUD();

    iud.executeIUD(
     "insert into PERSON_IDENTIFIER_TYPE " + 
     "(code, description, inactive_date) " + 
     "values ('EID', 'Employee ID', NULL)");

    iud.executeIUD(
     "insert into PERSON_IDENTIFIER_TYPE " + 
     "(code, description, inactive_date) " + 
     "values ('PHONE', 'Phone Number', NULL)");

    iud.executeIUD(
     "insert into PERSON_IDENTIFIER_TYPE " + 
     "(code, description, inactive_date) " + 
     "values ('SSN', 'Social Socurity Number', NULL)");

    iud.executeIUD(
     "update PERSON_IDENTIFIER_TYPE " + 
     "set description = 'Social Security Number' " +
     "where code = 'SSN'");

    iud.executeIUD(
     "delete PERSON_IDENTIFIER_TYPE " + 
     "where  code = 'PHONE'");