toolbox.dao
Class MetaDataHelper

Package class diagram package MetaDataHelper
java.lang.Object
  extended by toolbox.dao.MetaDataHelper

public class MetaDataHelper
extends java.lang.Object

Convenience class containing methods to return meta data from a database connection.


Constructor Summary
MetaDataHelper(java.sql.Connection conn)
          Construct a new helper with the given connection.
 
Method Summary
 void destroy()
          Destroy this helper
 java.util.List getColumns(java.lang.String table)
          Returns a list of column descriptions for a specific table.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataHelper

public MetaDataHelper(java.sql.Connection conn)
               throws java.sql.SQLException
Construct a new helper with the given connection.

Parameters:
conn - Database connection
Throws:
java.sql.SQLException
Method Detail

getColumns

public java.util.List getColumns(java.lang.String table)
                          throws java.sql.SQLException
Returns a list of column descriptions for a specific table. Each column descriptor is a HashMap instance.

The HashMap contains the following keys:

  • name - String containing the name of the column.
  • type - String containing the type of the column.
  • key - Type of key. For now the values are "primary" or "none".
  • null - Indicates whether NULL's are allowed. Possible values: "YES" or "NO"
  • extra - Indicates additional information. Current implementation only indicates auto increment fields using the value "auto".
  • Parameters:
    table - Table name.
    Returns:
    List of column descriptions.
    Throws:
    java.sql.SQLException

    destroy

    public void destroy()
                 throws java.sql.SQLException
    Destroy this helper

    Throws:
    java.sql.SQLException

    main

    public static void main(java.lang.String[] args)