rdbms
Class MetaBeanFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by rdbms.MetaBeanFrame
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class MetaBeanFrame
extends javax.swing.JFrame

Facade pattern implementation for JDBC This init method creates the connection to the database and retrieves additional database information.

Version:
1.00
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JFrame
EXIT_ON_CLOSE
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MetaBeanFrame()
          Constructor.
 
Method Summary
 void close()
          Closes the connections to this database.
 java.lang.String getCatalogName()
          Gets this Connection's current catalog name.
 int getColumnCount(java.sql.ResultSetMetaData _rsmd)
          Gets the number of columns in a ResultSet.
 java.lang.String[] getColumnTypeNames(java.sql.ResultSetMetaData _rsmd)
          Gets the database types of the columns in a ResultSet.
 java.lang.String getCurrentQuery()
          Gets the value of this current SQL.
 java.sql.DatabaseMetaData getDatabaseMetaData()
          Gets this DataBaseMetaData object.
 java.lang.String getDriverName()
          Gets the name of this JDBC driver.
 java.lang.String getKeyWords()
          Gets the keywords associated with this database.
 int getNumberofRows(java.util.Vector v)
          Converts a ResultSet to a Vector of Strings.
 java.lang.String getProductName()
          Gets the name of this database product.
 boolean getReadOnly()
          Gets whether or not this connection to this database is read only.
 java.util.Vector getRecords(java.sql.ResultSet _rs)
           
 java.sql.ResultSet getResultSet()
          Gets the ResultSet contained in this instance variable rs.
 java.sql.ResultSetMetaData getResultSetMetaData(java.sql.ResultSet _rs)
          Gets the MetaData for a specified ResultSet.
 java.lang.String[] getRowAsString(java.sql.ResultSet _rs)
          Converts a row in a ResultSet to a String.
 java.lang.String[] getTableFields(java.sql.ResultSetMetaData _rsmd)
          Gets the names of the columns (fields) in a provided ResultSet.
 java.lang.String getTableName()
          Gets the value of this current table name.
 java.lang.String[] getTableNames(java.sql.DatabaseMetaData dbmd, java.lang.String userid)
          Gets the table names contained in this current database.
 java.sql.ResultSet getTableTypes()
          Gets the table types available in this database connection.
 boolean getUsesLocalFiles()
          Determines if database uses a local file.
 void init()
          Loads specified driver and initializes the Connection to this Database.
 void modifyDatabase(java.sql.Connection c, java.lang.String sql)
          Process an SQL INSERT, DELETE or UPDATE statement string.
 void moveToTop(java.sql.ResultSet _rs)
          Moves to the top of this RecordSet.
 boolean nextRow(java.sql.ResultSet _rs)
          Moves to the next row of a provided ResultSet.
 void print(java.sql.ResultSet _rs)
          Prints the contents of a provided ResultSet.
 void printDataBaseInfo()
          Prints information about this database connection.
 void println(java.lang.Object o)
          Prints the contents of a provided Object.
 void println(java.lang.String[] s)
          Prints the contents of a String array.
 void printResultSetInfo(java.sql.ResultSet _rs)
          Prints information about this current ResultSet.
 java.sql.ResultSet query(java.sql.Connection c, java.lang.String sql)
          Creates a Result Set based on an sql query.
 void setDriver(java.lang.String _driver)
          Sets the name of the instance variable, driver, which this class is loadeding.
 void setPassword(java.lang.String _password)
          Sets this classes instance variable, password, for this database connection.
 void setTableName(java.lang.String _tablename)
          Sets this classes instance variable, tablename, for the current database tablename.
 void setUrl(java.lang.String _url)
          Sets this classes instance variable, url, for this database url.
 void setUserId(java.lang.String _userId)
          Sets this classes instance variable, userId, for this database connection.
 
Methods inherited from class javax.swing.JFrame
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

MetaBeanFrame

public MetaBeanFrame()
Constructor.

Method Detail

getUsesLocalFiles

public boolean getUsesLocalFiles()
Determines if database uses a local file. The value is set using the DatabaseMetaData. usesLocalFiles() method contained in the java.sql package. This method is called and this value is set in this classes init() method.

Returns:
true if it does, false if not

getReadOnly

public boolean getReadOnly()
Gets whether or not this connection to this database is read only. The value is set using the Connection.isReadOnly() method contained in the java.sql package. This method is called and this value is set in this classes init() method.

Returns:
true if it is, false if not

getCatalogName

public java.lang.String getCatalogName()
Gets this Connection's current catalog name. The value is set using the Connection.getCatalog() method contained in the java.sql package. This method is called and this value is set in this classes init() method.

Returns:
the current catalog name or null

getDriverName

public java.lang.String getDriverName()
Gets the name of this JDBC driver. The value is set using the DatabaseMetaData.getDriverName() method contained in the java.sql package. This method is called and this value is set in this classes init() method.

Returns:
the JDBC Driver name

getProductName

public java.lang.String getProductName()
Gets the name of this database product. The value is set using the DatabaseMetaData.getDatabaseProductName() method contained in the java.sql package. This method is called and this value is set in this classes init() method.

Returns:
the database product name

getResultSet

public java.sql.ResultSet getResultSet()
Gets the ResultSet contained in this instance variable rs.

Returns:
this classes ResultSet

getTableName

public java.lang.String getTableName()
Gets the value of this current table name. The value is set using the SqlBean.setTableName() method

Returns:
the current table name

getCurrentQuery

public java.lang.String getCurrentQuery()
Gets the value of this current SQL. The value is set using the SqlBean.query() method

Returns:
the current SQL query

getTableNames

public java.lang.String[] getTableNames(java.sql.DatabaseMetaData dbmd,
                                        java.lang.String userid)
Gets the table names contained in this current database. The table names are placed in a ResultSet using the DatabaseMetaData. getTables() method From the ResultSet, the tables are added to a vector and then converted into a String array. This method can be used affineTransform anytime after the init() method is called to set the DataBaseMetaData.

Returns:
the table names

getTableTypes

public java.sql.ResultSet getTableTypes()
Gets the table types available in this database connection. The results are ordered by table type. * The results are ordered by table type. Typical types are:
"TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL", "TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM". *

Returns:
the current SQL query

setUserId

public void setUserId(java.lang.String _userId)
Sets this classes instance variable, userId, for this database connection. This is the database user on whose behalf the Connection is being made for

Parameters:
_userId - the database UserId

setPassword

public void setPassword(java.lang.String _password)
Sets this classes instance variable, password, for this database connection. The password associated with the database user on whose behalf the Connection is being made for.

Parameters:
_password - the database Password

setUrl

public void setUrl(java.lang.String _url)
Sets this classes instance variable, url, for this database url. The url is in the form of jdbc:subprotocol:subname

Parameters:
_url - the database url

setDriver

public void setDriver(java.lang.String _driver)
Sets the name of the instance variable, driver, which this class is loadeding. This is the string representation of the driver being loaded to make the connection to the database.

Parameters:
_driver - the driver name

setTableName

public void setTableName(java.lang.String _tablename)
Sets this classes instance variable, tablename, for the current database tablename. *

Parameters:
_tablename - the database tablename

init

public void init()
Loads specified driver and initializes the Connection to this Database.

Loads the driver and Connects to the Database
Retrieves and sets Database/ Connection Information as follows:
    MetaData of this Database
    Read Only Property
    Uses Local Files Property
    Driver Name Used for the Connection
    Database Product Name
    Table Types in this Database


printDataBaseInfo

public void printDataBaseInfo()
Prints information about this database connection.


Prints the following information:
    The name of this database product
    This Connection's current catalog name
    Is this connection in read-only mode
    Does this database store tables in a local files
    The name of this JDBC driver
    The SQL keywords of this database
    The table types of all the tables in this database
    The names of all the tables in this database
    The names of all the non-system tables in this database


printResultSetInfo

public void printResultSetInfo(java.sql.ResultSet _rs)
Prints information about this current ResultSet.


Prints the following information:
    The column names (fields) of this database
    The type name of the columns (fields) used by this database

Parameters:
_rs - the current ResultSet

close

public void close()
Closes the connections to this database.


query

public java.sql.ResultSet query(java.sql.Connection c,
                                java.lang.String sql)
Creates a Result Set based on an sql query. *

Parameters:
c - the sql query
Returns:
the ResultSet

getResultSetMetaData

public java.sql.ResultSetMetaData getResultSetMetaData(java.sql.ResultSet _rs)
Gets the MetaData for a specified ResultSet. *

Parameters:
_rs - the ResultSet
Returns:
the ResultSetMetaData

getColumnCount

public int getColumnCount(java.sql.ResultSetMetaData _rsmd)
Gets the number of columns in a ResultSet. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
number of Columns (fields)

getKeyWords

public java.lang.String getKeyWords()
Gets the keywords associated with this database. *

Returns:
the keywords

getColumnTypeNames

public java.lang.String[] getColumnTypeNames(java.sql.ResultSetMetaData _rsmd)
Gets the database types of the columns in a ResultSet. These are the type name used by this database. If the column type is a user-defined type, then a fully-qualified type name is returned. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
the column types

getRowAsString

public java.lang.String[] getRowAsString(java.sql.ResultSet _rs)
Converts a row in a ResultSet to a String.

Parameters:
_rs - the ResultSet pointed to a particular row
Returns:
the contents of the ResultSet

getNumberofRows

public int getNumberofRows(java.util.Vector v)
Converts a ResultSet to a Vector of Strings.

Parameters:
_rs - the ResultSet
v - the Vector
Returns:
the vector containing the ResultSet with each row as a String / public java.util.Vector getRows(java.sql.ResultSet _rs) { java.util.Vector v = new java.util.Vector(); while (nextRow(_rs)) v.addElement(getRowAsString(_rs)); return v; } /** Returns the size of a vector. Used with the getRows() method that converts a ResultSet to a vector.

moveToTop

public void moveToTop(java.sql.ResultSet _rs)
Moves to the top of this RecordSet.

Parameters:
_rs - the ResultSet

print

public void print(java.sql.ResultSet _rs)
Prints the contents of a provided ResultSet. *

Parameters:
_rs - the ResultSet

getRecords

public java.util.Vector getRecords(java.sql.ResultSet _rs)

println

public void println(java.lang.Object o)
Prints the contents of a provided Object. * Uses the toString() method for the provided object.

Parameters:
o - the Object

println

public void println(java.lang.String[] s)
Prints the contents of a String array.

Parameters:
s - the array

nextRow

public boolean nextRow(java.sql.ResultSet _rs)
Moves to the next row of a provided ResultSet. *

Parameters:
_rs - the ResultSet

getTableFields

public java.lang.String[] getTableFields(java.sql.ResultSetMetaData _rsmd)
Gets the names of the columns (fields) in a provided ResultSet. *

Parameters:
_rsmd - the ResultSetMetaData
Returns:
the table names

getDatabaseMetaData

public java.sql.DatabaseMetaData getDatabaseMetaData()
Gets this DataBaseMetaData object.

Returns:
this DataBaseMetaData

modifyDatabase

public void modifyDatabase(java.sql.Connection c,
                           java.lang.String sql)
Process an SQL INSERT, DELETE or UPDATE statement string. Additionally, this could be an SQL statement that returns nothing such as SQL DDL statments.

Parameters:
sql - the SQL INSERT, UPDATE or DELETE statement or an SQL statement that returns nothing