⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dynamic.java

📁 有关JDBC的使用一些编程实例,有关与数据库连接的代码
💻 JAVA
字号:
/*
 Copyright 1996 John Wiley & Sons, Inc. All Rights Reserved. Reproduction
 or translation of this work beyond that permitted in Section 117 of the 1976
 United States Copyright Act without the express written permission of the
 copyright owner is unlawful. Requests for further information should be 
 addressed to Permissions Department, John Wiley & Sons, Inc. The 
 purchaser may make back-up copies for his/her own use only and not for 
 distribution or resale. The Publisher assumes no responsibility for errors, 
 omissions, or damages, caused by the use of this  software or from the use
 of the information contained herein.
*/

import java.util.*;

public class Dynamic {

  public static void main(String argv[]) {

    // a new Vector object to hold all the rows

    Vector rows = new Vector();

    // populate the data structure with some bogus
    // values that might appear in a table

    popData(rows, "Brian", "Jepson");
    popData(rows, "Mr.",   "Kite");
    popData(rows, "Mr.",   "Mustard");
    popData(rows, "Japhy", "Ryder");

    // process each row in the "table"

    for (int i = 0; i < rows.size(); i++) {

      // get the Hashtable that is contained in each row

      Hashtable foo = (Hashtable) rows.elementAt(i);

      // print out the row number - but add one to it
	// since the index offset is zero, but most
	// people are used to seeing records/rows start
	// at one.

      System.out.println("Row " + (i + 1));

      // since foo is the Hashtable for the current row,
      // you can get the column by invoking the get()
      // method with the name of the column you want.

      System.out.println("  first_name = " + foo.get("first_name"));
      System.out.println("  last_name  = " + foo.get("last_name"));

    }

    // exit cleanly

    System.exit(0);

  }

  // a convenience method to add items to the "table"

  public static void popData(Vector rows, String first, String last) {

    // create a new Hashtable

    Hashtable columns = new Hashtable();

    // add the data to the new Hashtable

    columns.put("first_name", first);
    columns.put("last_name",  last);
    
    // add the Hashtable to the Vector

    rows.addElement(columns);

  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -