Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

An easy JDBC wrapper

A quick data access solution for simple programs


Row.java listing
// $Id$

import java.util.*;

public class Row
{
  private Vector ordering = new Vector();
  private Hashtable hashtable = new Hashtable();

  public Row() {
  }

  public void put( String name, String value ) {
    if (!hashtable.containsKey( name))
      ordering.addElement( name );
    hashtable.put( name, value );
  }

  public int length() {
    return hashtable.size();
  }

  public String get( String name ) {
    return (String)hashtable.get( name );
  }

  public String get( int which ) {
    String key = (String)ordering.elementAt( which );
    return (String)hashtable.get( key );
  }

  public String getKey( int which ) {
    String key = (String)ordering.elementAt( which );
    return key;
  }

  public void dump() {
    for (Enumeration e=hashtable.keys(); e.hasMoreElements();) {
      String name = (String)e.nextElement();
      String value = (String)hashtable.get( name );
      System.out.print( name+"="+value+", " );
    }
    System.out.println( "" );
  }
}

Return to the article.