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

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

public class CreateTCDatabase
extends Object

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

Version:
$Revision: 2649 $
Author:
Prasanth Thomas

Field Summary
private  String CHECK_DB_EXISTS_STMT
          MySQL statement for checking if DB exists
private  String CREATE_DATABASE_STMT
          MySQL statement for checking for creating database
private  String DROP_DATABASE_STMT
          MySQL statement for checking for dropping database
protected  Connection mConnection
          Maintains the connection to the database over the lifetime of this instance.
private  String mDatabaseAbsolutePath
          Stores the absolute path to the mysql home directory
private  String mDatabaseHost
          Stores the database host name
private  String mDatabaseName
          Stores the database name
private  String mDriver
          Stores the driver string
private  LogManager mLogger
          The default logger.
private  String mPassword
          Stores the MySQL password
private  String mUrl
          Stores the database url
private  String mUsername
          Stores the user name
 
Constructor Summary
CreateTCDatabase(String driver, String url, String username, String password, String host)
          Creates a JDBCTC instance .
 
Method Summary
 boolean checkIfDatabaseExists(String databaseName)
          Checks if the given database exists
 boolean createDatabase(String databaseName)
          Creates data base
 boolean deleteDatabase(String databaseName)
          Deletes the database
 String getDatabaseName(String dbURL)
          Returns the database name from the database url string
 boolean initializeDatabase(String databaseName, 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 Connection mConnection
Maintains the connection to the database over the lifetime of this instance.


CHECK_DB_EXISTS_STMT

private String CHECK_DB_EXISTS_STMT
MySQL statement for checking if DB exists


DROP_DATABASE_STMT

private String DROP_DATABASE_STMT
MySQL statement for checking for dropping database


CREATE_DATABASE_STMT

private String CREATE_DATABASE_STMT
MySQL statement for checking for creating database


mDriver

private String mDriver
Stores the driver string


mUrl

private String mUrl
Stores the database url


mUsername

private String mUsername
Stores the user name


mPassword

private String mPassword
Stores the MySQL password


mDatabaseName

private String mDatabaseName
Stores the database name


mDatabaseHost

private String mDatabaseHost
Stores the database host name


mDatabaseAbsolutePath

private String mDatabaseAbsolutePath
Stores the absolute path to the mysql home directory

Constructor Detail

CreateTCDatabase

public CreateTCDatabase(String driver,
                        String url,
                        String username,
                        String password,
                        String host)
                 throws ClassNotFoundException,
                        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:
ClassNotFoundException - if it fails to load the driver
SQLException
Method Detail

getDatabaseName

public String getDatabaseName(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(String databaseName)
                              throws SQLException
Checks if the given database exists

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

deleteDatabase

public boolean deleteDatabase(String databaseName)
                       throws SQLException
Deletes the database

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

createDatabase

public boolean createDatabase(String databaseName)
                       throws SQLException
Creates data base

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

initializeDatabase

public boolean initializeDatabase(String databaseName,
                                  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.


Copyright © 2011 The University of Southern California. All Rights Reserved.