Class CreateTCDatabase
- java.lang.Object
-
- edu.isi.pegasus.planner.catalog.transformation.impl.CreateTCDatabase
-
public class CreateTCDatabase extends java.lang.ObjectThis class provides a bridge for creating and initializing transformation catalog on database .- Version:
- $Revision$
- Author:
- Prasanth Thomas
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringCHECK_DB_EXISTS_STMTMySQL statement for checking if DB existsprivate java.lang.StringCREATE_DATABASE_STMTMySQL statement for checking for creating databaseprivate java.lang.StringDROP_DATABASE_STMTMySQL statement for checking for dropping databaseprotected java.sql.ConnectionmConnectionMaintains the connection to the database over the lifetime of this instance.private java.lang.StringmDatabaseAbsolutePathStores the absolute path to the mysql home directoryprivate java.lang.StringmDatabaseHostStores the database host nameprivate java.lang.StringmDatabaseNameStores the database nameprivate java.lang.StringmDriverStores the driver stringprivate LogManagermLoggerThe default logger.private java.lang.StringmPasswordStores the MySQL passwordprivate java.lang.StringmUrlStores the database urlprivate java.lang.StringmUsernameStores the user name
-
Constructor Summary
Constructors Constructor 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 Modifier and Type Method Description booleancheckIfDatabaseExists(java.lang.String databaseName)Checks if the given database existsbooleancreateDatabase(java.lang.String databaseName)Creates data basebooleandeleteDatabase(java.lang.String databaseName)Deletes the databasejava.lang.StringgetDatabaseName(java.lang.String dbURL)Returns the database name from the database url stringbooleaninitializeDatabase(java.lang.String databaseName, java.lang.String fileName)Initialize the database with given .sql file
-
-
-
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.SQLExceptionCreates a JDBCTC instance . Supports only MySQL connection for the time being- Parameters:
driver- the Database driverurl- the Database urlusername- the Database user namepassword- the Database user password- Throws:
java.lang.ClassNotFoundException- if it fails to load the driverjava.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.SQLExceptionChecks 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.SQLExceptionDeletes 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.SQLExceptionCreates 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 namefileName- the file name- Returns:
- true, if initialization succeeds, false otherwise.
-
-