edu.isi.pegasus.planner.catalog.transformation.impl

## Class CreateTCDatabase

- java.lang.Object
- - edu.isi.pegasus.planner.catalog.transformation.impl.CreateTCDatabase

    public class CreateTCDatabase
    extends java.lang.Object

This class provides a bridge for creating and initializing transformation catalog on database .

Version:
  $Revision$
Author:
  Prasanth Thomas

### Field Summary

Fields
`private java.lang.String` `CHECK_DB_EXISTS_STMT` MySQL statement for checking if DB exists
`private java.lang.String` `CREATE_DATABASE_STMT` MySQL statement for checking for creating database
`private java.lang.String` `DROP_DATABASE_STMT` MySQL statement for checking for dropping database
`protected java.sql.Connection` `mConnection` Maintains the connection to the database over the lifetime of this instance.
`private java.lang.String` `mDatabaseAbsolutePath` Stores the absolute path to the mysql home directory
`private java.lang.String` `mDatabaseHost` Stores the database host name
`private java.lang.String` `mDatabaseName` Stores the database name
`private java.lang.String` `mDriver` Stores the driver string
`private LogManager` `mLogger` The default logger.
`private java.lang.String` `mPassword` Stores the MySQL password
`private java.lang.String` `mUrl` Stores the database url
`private java.lang.String` `mUsername` Stores the user name

### Constructor Summary

Constructors
Constructor and Description
`CreateTCDatabase(java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String host)` Creates a JDBCTC instance .

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `checkIfDatabaseExists(java.lang.String databaseName)` Checks if the given database exists
`boolean` `createDatabase(java.lang.String databaseName)` Creates data base
`boolean` `deleteDatabase(java.lang.String databaseName)` Deletes the database
`java.lang.String` `getDatabaseName(java.lang.String dbURL)` Returns the database name from the database url string
`boolean` `initializeDatabase(java.lang.String databaseName, java.lang.String fileName)` Initialize the database with given .sql file

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### mLogger

    private LogManager mLogger

The default logger.

#### mConnection

    protected java.sql.Connection mConnection

Maintains the connection to the database over the lifetime of this instance.

#### CHECK_DB_EXISTS_STMT

    private java.lang.String CHECK_DB_EXISTS_STMT

MySQL statement for checking if DB exists

#### DROP_DATABASE_STMT

    private java.lang.String DROP_DATABASE_STMT

MySQL statement for checking for dropping database

#### CREATE_DATABASE_STMT

    private java.lang.String CREATE_DATABASE_STMT

MySQL statement for checking for creating database

#### mDriver

    private java.lang.String mDriver

Stores the driver string

#### mUrl

    private java.lang.String mUrl

Stores the database url

#### mUsername

    private java.lang.String mUsername

Stores the user name

#### mPassword

    private java.lang.String mPassword

Stores the MySQL password

#### mDatabaseName

    private java.lang.String mDatabaseName

Stores the database name

#### mDatabaseHost

    private java.lang.String mDatabaseHost

Stores the database host name

#### mDatabaseAbsolutePath

    private java.lang.String mDatabaseAbsolutePath

Stores the absolute path to the mysql home directory

### Constructor Detail

#### CreateTCDatabase

    public CreateTCDatabase(java.lang.String driver,
                            java.lang.String url,
                            java.lang.String username,
                            java.lang.String password,
                            java.lang.String host)
                     throws java.lang.ClassNotFoundException,
                            java.sql.SQLException

Creates a JDBCTC instance . Supports only MySQL connection for the time being

Parameters:
  `driver` - the Database driver
  `url` - the Database url
  `username` - the Database user name
  `password` - the Database user password
Throws:
  `java.lang.ClassNotFoundException` - if it fails to load the driver
  `java.sql.SQLException`

### Method Detail

#### getDatabaseName

    public java.lang.String getDatabaseName(java.lang.String dbURL)

Returns the database name from the database url string

Parameters:
  `dbURL` - the database url string
Returns:
  the database name, null if it does not contain a database name

#### checkIfDatabaseExists

    public boolean checkIfDatabaseExists(java.lang.String databaseName)
                                  throws java.sql.SQLException

Checks if the given database exists

Parameters:
  `databaseName` - the database name
Returns:
  true if database schema exists, false otherwise
Throws:
  `java.sql.SQLException`

#### deleteDatabase

    public boolean deleteDatabase(java.lang.String databaseName)
                           throws java.sql.SQLException

Deletes the database

Parameters:
  `databaseName` - the database
Returns:
  true, if database is deleted , false otherwise
Throws:
  `java.sql.SQLException`

#### createDatabase

    public boolean createDatabase(java.lang.String databaseName)
                           throws java.sql.SQLException

Creates data base

Parameters:
  `databaseName` - the database name
Returns:
  true, if database is created , false otherwise
Throws:
  `java.sql.SQLException`

#### initializeDatabase

    public boolean initializeDatabase(java.lang.String databaseName,
                                      java.lang.String fileName)

Initialize the database with given .sql file

Parameters:
  `databaseName` - the database name
  `fileName` - the file name
Returns:
  true, if initialization succeeds, false otherwise.