|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
cox.jmatt.java.MathTools.demo.MathDBCDemo
public class MathDBCDemo
This class serves as a MathDBC
demo and as a JDBC tool. Although not visible MathDBC
is used to create a Connection
to the specified database. The Driver class name and JDBC URL are configured on the Config panel and the main area holds SQL commands to be executed. The
Login Properties panel holds properties that are used when establishing a Driver Connection
and an URLLoaderPanel
rounds out the
mix. The Loader panel is used to set the CapCom
Math ClassLoader for the MathDBC
instance to use.
If the last SQL statement executed generates a ResultSet
it can be printed via a MathTestFormatter
. The config panel holds a
TextField for the template String and the output can be sent to the clipboard. (BasicMathPrinter processMathObject()
). No formatting tokens other
than the ResultSet
or built-in ones are available but those should suffice.
In its second role MathDBCDemo
allows 'raw' SQL to be executed using JDBC. While there are many other tools dedicated solely to that purpose none
of them are included in MathTools! This tool allows the quick creation or manipulation of a JDBC-enabled database without needing to wrap the SQL in scripting
language statements. This means a database can be created quickly from nothing but SQL. It is also possible to execute queries against it, quickly and from
within MathTools, after it has been created.
Besides quick database creation MathDBCDemo
allows SQL experimentation. This makes it possible to 'debug' SQL statements before including them
in scripts, without resorting to an external tool.
MathDBCDemo
defines a set of macro commands
that allow in-line configuration and debugging. These commands are all
two characters in length, the first of which is a slash. All necessary information, such as Driver class name and JDBC connection URL, can be specified
within the SQL commands. The echo command ('/e') prints a message and the break command ('/x') STOPS execution. This allows SQL debugging with single
line progressive granularity. This means a LONG batch of SQL can be debugged without the need for massive amounts of typing or re-loading.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.lang.String |
KEY_CONFIG
This is the constant key used to select the configuration panel. |
static java.lang.String |
KEY_PROPS
This is the constant key used to select the connect() panel. |
static java.lang.String |
KEY_SQL
This is the constant key used to select the SQL entry panel in the main display area. |
static java.lang.String |
KEY_URL
This is the constant key used to select the URL ClassLoader. |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
MathDBCDemo()
Zero-argument constructor. |
|
MathDBCDemo(java.awt.Dialog pParent)
Build the demo around a Dialog . |
|
MathDBCDemo(java.awt.Frame pParent)
Build the demo around a Dialog . |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent aev)
Handle all button clicks. |
void |
clearProps(boolean pOkToClear)
Clear the parameter area. |
void |
clearSQL(boolean pOkToClear)
Clear the SQL area. |
java.awt.Panel |
configPanel()
This is the configuration Panel. |
void |
executeSQL()
This method executes the SQL statements in the main Panel. |
java.lang.String |
getDriver()
Get the current driver name. |
java.lang.String |
getJDBC()
Get the current database URL. |
java.util.Properties |
getPizza()
Parse the config Properties object and return it. |
java.lang.String |
getSQL()
Fetch the current SQL commands. |
java.lang.String |
getTemplate()
Get the current row format template. |
void |
loadFile(java.lang.String pKey)
Load a script or pizza from a FileDialog. |
void |
loadFile(java.lang.String pFile,
java.lang.String pKey)
Load a script or Properties from a file. |
java.awt.Panel |
loginPropsPanel()
This Panel holds the Properties object used to enter database login parameters. |
boolean |
processMacroCommand(java.lang.String pCmd)
This method processes any macro commands embedded within SQL comments. |
void |
setDriver(java.lang.String pDriver)
Set the name of the JDBC driver. |
void |
setJDBC(java.lang.String pJDBC)
Set the database URL. |
void |
setSQL(java.lang.String pScript)
Put SQL commands in the SQL Entry Area. |
void |
setTemplate(java.lang.String pTemplate)
Set the row format template. |
java.awt.Panel |
SQLEntryPanel()
This is the Panel used to enter the SQL commands. |
java.awt.Panel |
standardGUI()
This method builds the standard GUI and returns itself as a reference. |
Methods inherited from class java.awt.Panel |
---|
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String KEY_SQL
public static final java.lang.String KEY_PROPS
connect()
panel.
public static final java.lang.String KEY_CONFIG
public static final java.lang.String KEY_URL
Constructor Detail |
---|
public MathDBCDemo()
FileDialog
functionality will not be present.
public MathDBCDemo(java.awt.Dialog pParent)
Dialog
. All functions available.
public MathDBCDemo(java.awt.Frame pParent)
Dialog
. All functions available.
Method Detail |
---|
public final java.awt.Panel standardGUI()
public final java.awt.Panel SQLEntryPanel()
public final java.awt.Panel configPanel()
public final java.awt.Panel loginPropsPanel()
public final void actionPerformed(java.awt.event.ActionEvent aev)
actionPerformed
in interface java.awt.event.ActionListener
public java.util.Properties getPizza()
public void loadFile(java.lang.String pKey)
pKey
- The KEY_ constant determining where to load.public void loadFile(java.lang.String pFile, java.lang.String pKey)
pFile
- The name of the file to load.pKey
- The place to send the loaded file.public java.lang.String getSQL()
public void setSQL(java.lang.String pScript)
public java.lang.String getDriver()
public void setDriver(java.lang.String pDriver)
public java.lang.String getJDBC()
public void setJDBC(java.lang.String pJDBC)
public java.lang.String getTemplate()
public void setTemplate(java.lang.String pTemplate)
public void clearSQL(boolean pOkToClear)
pOkToClear
- true to REALLY clear the area, false not to.public void clearProps(boolean pOkToClear)
pOkToClear
- true to REALLY clear the config props.public void executeSQL()
This method executes the SQL statements in the main Panel. If the last statement executed returns a ResultSet and the 'format result' Checkbox is enabled
it is sent to a MathTestFormatter
for formatting. The formatting template is entered in the 'template' TextArea. If the 'processMathObject()'
Checkbox is enabled the resulting String is sent to CapCom.processMathObject()
, which sends it to the clipboard.
public boolean processMacroCommand(java.lang.String pCmd)
This method processes any macro commands embedded within SQL comments. The macro commands allow configuration values to be set. The macro commands all start with a slash character ('/') and consist of a single letter followed by the data to be configured. The command line must start with a double hyphen followed by a single space: '-- ' and then the command. The macro commands are as follows.
Driver
.Uppercase letters will also work.
NOTE: The macro commands are embedded within SQL line comments. In order to be executed the (trimmed) line must start with a double hyphen followed by at least one space. The macro parser ignores any line that does not begin '-- ' and further ignores lines whose fourth character is not a slash.
pCmd
- The macro command to execute.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |