proper.database
Class Creator

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.database.Creator
All Implemented Interfaces:
ProperInterface

public class Creator
extends ProperObject

This class creates databases on a given host.

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
static java.lang.String NAME
          the placeholder for the name
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
Creator()
          initializes the object (it initializes with the MySQL driver)
Creator(java.lang.String url)
          connects with the MySQL-Driver to the given host/database
Creator(java.lang.String url, java.lang.String user)
          connects with the MySQL-Driver to the given host/database w/o password
Creator(java.lang.String url, java.lang.String user, java.lang.String password)
          connects with the MySQL-Driver to the given host/database with user/pw
Creator(java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password)
          connects to the database with the given driver, url, etc.
 
Method Summary
 boolean create(java.lang.String name)
          creates the database if not existing
 boolean exists(java.lang.String name)
          checks whether the database already exists
 java.lang.String getCreateStatement()
          returns the SQL statement for creating databases on the host, includes the placeholder NAME
 java.lang.Exception getLastException()
          returns the last exception, can be null
 java.lang.String getLastStatement()
          returns the last SQL statement
 void setCreateStatement(java.lang.String statement)
          sets the SQL statement for creating the databases on the host, includes the placeholder NAME
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
the placeholder for the name

See Also:
setCreateStatement(String), Constant Field Values
Constructor Detail

Creator

public Creator()
        throws java.lang.Exception
initializes the object (it initializes with the MySQL driver)

Throws:
java.lang.Exception

Creator

public Creator(java.lang.String url)
        throws java.lang.Exception
connects with the MySQL-Driver to the given host/database

Parameters:
url - the url consists of jdbc:subprotocol://host[:port]/
Throws:
java.lang.Exception

Creator

public Creator(java.lang.String url,
               java.lang.String user)
        throws java.lang.Exception
connects with the MySQL-Driver to the given host/database w/o password

Parameters:
url - the url consists of jdbc:subprotocol://host[:port]/
user - the user to connect as
Throws:
java.lang.Exception

Creator

public Creator(java.lang.String url,
               java.lang.String user,
               java.lang.String password)
        throws java.lang.Exception
connects with the MySQL-Driver to the given host/database with user/pw

Parameters:
url - the url consists of jdbc:subprotocol://host[:port]/
user - the user to connect as
password - the corresponding password
Throws:
java.lang.Exception

Creator

public Creator(java.lang.String driver,
               java.lang.String url,
               java.lang.String user,
               java.lang.String password)
        throws java.lang.Exception
connects to the database with the given driver, url, etc.

Parameters:
driver - the class to use as driver
url - the url consists of jdbc:subprotocol://host[:port]/
user - the user to connect as
password - the corresponding password
Throws:
java.lang.Exception
Method Detail

setCreateStatement

public void setCreateStatement(java.lang.String statement)
sets the SQL statement for creating the databases on the host, includes the placeholder NAME

Parameters:
statement - the SQL statement
See Also:
NAME

getCreateStatement

public java.lang.String getCreateStatement()
returns the SQL statement for creating databases on the host, includes the placeholder NAME

Returns:
the SQL statement
See Also:
NAME

exists

public boolean exists(java.lang.String name)
checks whether the database already exists


create

public boolean create(java.lang.String name)
creates the database if not existing


getLastException

public java.lang.Exception getLastException()
returns the last exception, can be null


getLastStatement

public java.lang.String getLastStatement()
returns the last SQL statement