Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.tools.db
Class DBSetup

java.lang.Object
  extended by org.hyperic.tools.db.DBSetup

public class DBSetup
extends java.lang.Object

To Do: - implement abstract factory for tables,columns,views,etc - the "if dbtype" stuff is yucky - The verbose/quiet System.out'ing stuff should go away in favor of commons-logging - hungarian notation must be destroyed - schema diff'ing (semantic diff, not xml file diff or something) - fix how the driver classes are loaded and the relationship to org.hyperic.util.jdbc.JDBC (do you load drivers with just database name or by deriving the drivername from the database name and then loading it, both seem to happening now, which is bad) - fix up terminology ("create" should be "rdbms-export", "setup" should be "rdbms-import" or something else) to more descriptive


Field Summary
static boolean m_bDMLonly
           
 
Constructor Summary
DBSetup()
          Constructs a DBSetup class with quiet mode turned on.
DBSetup(boolean quiet)
          Constructs a DBSetup object with quiet mode turned on or off.
DBSetup(boolean quiet, boolean verbose)
          Constructs a DBSetup object with quiet mode turned on or off.
DBSetup(boolean quiet, boolean verbose, boolean nonInteractive, java.lang.String logFileName, boolean append, boolean noexec)
           
 
Method Summary
 boolean clear(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password)
           
 boolean clear(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password, java.lang.String table)
           
protected static org.w3c.dom.Node copyNode(org.w3c.dom.Document target, org.w3c.dom.Node source, boolean deep)
           
 void create(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password)
           
protected  boolean doSetup(java.lang.Object source, java.lang.String database, java.lang.String username, java.lang.String password)
           
protected  boolean doSetup(java.lang.Object source, java.lang.String database, java.lang.String username, java.lang.String password, java.lang.String table, boolean doDelete)
           
protected  void doSQL(java.lang.String cmd)
           
protected  java.sql.Statement doSQL(java.lang.String cmd, boolean bPrepared)
          Thou shalt be responsible for .close()'ing the returned prepared statement when they're through, lest they suffer a cursor flood
protected  boolean doUninstall(java.lang.Object source, java.lang.String database, java.lang.String username, java.lang.String password)
           
protected  java.sql.Connection getConn()
           
protected  int getDbType()
           
protected static void importChildNodes(org.w3c.dom.Node parent, org.w3c.dom.Node source, boolean deep)
           
protected static void importNodeAfter(org.w3c.dom.Node after, org.w3c.dom.Node source, boolean deep)
           
 void init(boolean verbose, boolean sqlonly)
           
 boolean isNoninteractive()
          Retrieves whether questions should be asked on stdin.
 boolean isQuiet()
          Retrieves whether status messages will be printed to System.out.
 boolean isVerbose()
          Retrieves whether status messages will be printed to System.out.
 void logSQL(java.lang.String sql)
           
 org.w3c.dom.Document newDocument()
           
 org.w3c.dom.Document readDocument(java.io.InputStream is)
           
 org.w3c.dom.Document readDocument(java.lang.Object source, org.w3c.dom.Node after)
           
 org.w3c.dom.Document readDocument(java.lang.String file)
           
 void setNoninteractive(boolean noninteractive)
          Sets whether questions should be asked on stdin.
 void setQuiet(boolean quiet)
          Sets whether status messages will be printed to System.out.
 void setTypeMapFile(java.lang.String tmapFile)
           
 void setTypeMapStream(java.io.InputStream is)
           
 boolean setup(java.io.InputStream is, java.lang.String database, java.lang.String username, java.lang.String password)
           
 boolean setup(java.lang.String file, java.lang.String database)
           
 boolean setup(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password)
           
 boolean setup(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password, java.lang.String table, boolean doDelete)
           
 void setVerbose(boolean quiet)
          Sets whether status messages will be printed to System.out.
 boolean uninstall(java.io.InputStream is, java.lang.String database, java.lang.String username, java.lang.String password)
           
 boolean uninstall(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password)
           
 boolean validate(java.lang.String file, java.lang.String database, java.lang.String username, java.lang.String password)
           
 void writeDocument(org.w3c.dom.Document doc, java.lang.String file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_bDMLonly

public static boolean m_bDMLonly
Constructor Detail

DBSetup

public DBSetup()
Constructs a DBSetup class with quiet mode turned on.


DBSetup

public DBSetup(boolean quiet)
Constructs a DBSetup object with quiet mode turned on or off.

Parameters:
quiet - Status messages are sent to std out if true, no message otherwise.

DBSetup

public DBSetup(boolean quiet,
               boolean verbose)
Constructs a DBSetup object with quiet mode turned on or off.

Parameters:
quiet - Status messages are sent to stdout if true, no messages otherwise.
verbose - SQL Commands and other verbose information is sent to stdout if true, no verbose messages otherwise.

DBSetup

public DBSetup(boolean quiet,
               boolean verbose,
               boolean nonInteractive,
               java.lang.String logFileName,
               boolean append,
               boolean noexec)
Method Detail

create

public void create(java.lang.String file,
                   java.lang.String database,
                   java.lang.String username,
                   java.lang.String password)
            throws java.lang.ClassNotFoundException,
                   java.io.IOException,
                   java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

newDocument

public org.w3c.dom.Document newDocument()
                                 throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

copyNode

protected static org.w3c.dom.Node copyNode(org.w3c.dom.Document target,
                                           org.w3c.dom.Node source,
                                           boolean deep)

importNodeAfter

protected static void importNodeAfter(org.w3c.dom.Node after,
                                      org.w3c.dom.Node source,
                                      boolean deep)

importChildNodes

protected static void importChildNodes(org.w3c.dom.Node parent,
                                       org.w3c.dom.Node source,
                                       boolean deep)

readDocument

public org.w3c.dom.Document readDocument(java.lang.String file)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

readDocument

public org.w3c.dom.Document readDocument(java.io.InputStream is)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

readDocument

public org.w3c.dom.Document readDocument(java.lang.Object source,
                                         org.w3c.dom.Node after)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

writeDocument

public void writeDocument(org.w3c.dom.Document doc,
                          java.lang.String file)
                   throws java.io.IOException,
                          org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException

setup

public boolean setup(java.lang.String file,
                     java.lang.String database)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

setup

public boolean setup(java.lang.String file,
                     java.lang.String database,
                     java.lang.String username,
                     java.lang.String password)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

setup

public boolean setup(java.lang.String file,
                     java.lang.String database,
                     java.lang.String username,
                     java.lang.String password,
                     java.lang.String table,
                     boolean doDelete)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

setup

public boolean setup(java.io.InputStream is,
                     java.lang.String database,
                     java.lang.String username,
                     java.lang.String password)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

doSetup

protected boolean doSetup(java.lang.Object source,
                          java.lang.String database,
                          java.lang.String username,
                          java.lang.String password)
                   throws java.lang.ClassNotFoundException,
                          java.io.IOException,
                          java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

doSetup

protected boolean doSetup(java.lang.Object source,
                          java.lang.String database,
                          java.lang.String username,
                          java.lang.String password,
                          java.lang.String table,
                          boolean doDelete)
                   throws java.lang.ClassNotFoundException,
                          java.io.IOException,
                          java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

clear

public boolean clear(java.lang.String file,
                     java.lang.String database,
                     java.lang.String username,
                     java.lang.String password)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

clear

public boolean clear(java.lang.String file,
                     java.lang.String database,
                     java.lang.String username,
                     java.lang.String password,
                     java.lang.String table)
              throws java.lang.ClassNotFoundException,
                     java.io.IOException,
                     java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

uninstall

public boolean uninstall(java.lang.String file,
                         java.lang.String database,
                         java.lang.String username,
                         java.lang.String password)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException,
                         java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

uninstall

public boolean uninstall(java.io.InputStream is,
                         java.lang.String database,
                         java.lang.String username,
                         java.lang.String password)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException,
                         java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

doUninstall

protected boolean doUninstall(java.lang.Object source,
                              java.lang.String database,
                              java.lang.String username,
                              java.lang.String password)
                       throws java.lang.ClassNotFoundException,
                              java.io.IOException,
                              java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

validate

public boolean validate(java.lang.String file,
                        java.lang.String database,
                        java.lang.String username,
                        java.lang.String password)
                 throws java.lang.ClassNotFoundException,
                        java.io.IOException,
                        java.sql.SQLException
Throws:
java.lang.ClassNotFoundException
java.io.IOException
java.sql.SQLException

isQuiet

public boolean isQuiet()
Retrieves whether status messages will be printed to System.out.

Returns:
boolean true if status messages will be printed, false otherwise.

setQuiet

public void setQuiet(boolean quiet)
Sets whether status messages will be printed to System.out.

Parameters:
quiet - true if status messages should be printed, false otherwise.

isNoninteractive

public boolean isNoninteractive()
Retrieves whether questions should be asked on stdin.

Returns:
boolean true if questions will be asked, false otherwise.

setNoninteractive

public void setNoninteractive(boolean noninteractive)
Sets whether questions should be asked on stdin.

Parameters:
noninteractive - true if questions should be asked, false otherwise.

isVerbose

public boolean isVerbose()
Retrieves whether status messages will be printed to System.out.

Returns:
boolean true if status messages will be printed, false otherwise.

setVerbose

public void setVerbose(boolean quiet)
Sets whether status messages will be printed to System.out.

Parameters:
quiet - true if status messages should be printed, false otherwise.

doSQL

protected void doSQL(java.lang.String cmd)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

doSQL

protected java.sql.Statement doSQL(java.lang.String cmd,
                                   boolean bPrepared)
                            throws java.sql.SQLException
Thou shalt be responsible for .close()'ing the returned prepared statement when they're through, lest they suffer a cursor flood

Throws:
java.sql.SQLException

getConn

protected java.sql.Connection getConn()

setTypeMapFile

public void setTypeMapFile(java.lang.String tmapFile)

setTypeMapStream

public void setTypeMapStream(java.io.InputStream is)

init

public void init(boolean verbose,
                 boolean sqlonly)

logSQL

public void logSQL(java.lang.String sql)

getDbType

protected int getDbType()

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.