|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.udo.cs.miningmart.db.DbCore
edu.udo.cs.miningmart.db.DbCoreMysql
public class DbCoreMysql
This class provides an access to a MySQL DBMS. It has only been tested with MySQL version 5.0.3. See www.mysql.com To compile this class, the MySQL JDBC driver package must be added to the classpath.
| Field Summary | |
|---|---|
static java.lang.String |
MYSQL_TYPE_CHAR
The public constant indicating the Mysql Datatype CHAR |
static java.lang.String |
MYSQL_TYPE_DATE
The public constant indicating the Mysql Datatype DATE |
static java.lang.String |
MYSQL_TYPE_INTEGER
The public constant indicating the Mysql Datatype INTEGER |
static java.lang.String |
MYSQL_TYPE_NUMBER
The public constant indicating the Mysql Datatype DOUBLE |
static java.lang.String |
MYSQL_TYPE_STRING
The public constant indicating the Mysql Datatype VARCHAR |
static java.lang.String |
MYSQL_TYPE_TEXT
The public constant indicating the Mysql Datatype TEXT |
static java.lang.String |
MYSQL_TYPE_TIME
The public constant indicating the Mysql Datatype TIME |
static java.lang.String |
MYSQL_TYPE_TIMESTAMP
The public constant indicating the Mysql Datatype TIMESTAMP |
| Fields inherited from class edu.udo.cs.miningmart.db.DbCore |
|---|
DBMS_MYSQL, DBMS_ORACLE, DBMS_POSTGRES, mySchemaName |
| Constructor Summary | |
|---|---|
DbCoreMysql(java.lang.String url,
java.lang.String dbName,
java.lang.String user,
java.lang.String passwd,
M4InterfaceContext cal,
boolean isM4Schema)
The constructor of this class calls the constructor of the superclass DbCore. |
|
| Method Summary | |
|---|---|
void |
createForeignKeyConstraint(java.lang.String fkTableName,
java.util.Collection fkAttributeNames,
java.lang.String pkTableName,
java.util.Collection pkAttributeNames,
java.lang.String dbConstraintName)
This method creates a foreign key constraint in the database. |
java.lang.String |
createPrimaryKeyConstraint(java.lang.String tableName,
java.util.Collection pkAttributeNames,
java.lang.String dbConstraintName)
Creates a primary key constraint in the database. |
boolean |
dropRelation(java.lang.String tableName)
Try to drop the table or view with the given name, if it exists. |
java.lang.String |
getAliasExpressionForInnerSelects(java.lang.String aliasName)
Abstract method to be implemented by the subclasses. |
java.lang.String |
getAttributeForColumnNames()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getAttributeForColumnTypes()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getDatatypeName(java.lang.String m4RelDatatypeName,
int size)
This method returns the DBMS-dependent name of the datatype which the current DBMS uses to realize the given M4-Relational Datatype. |
short |
getDbms()
Indicates the DBMS used. |
java.lang.String |
getFloorExpression()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getM4DatatypeName(java.lang.String dbmsDatatypeName)
This method returns the M4-Relational Datatype that corresponds to the given DBMS-dependent name of a datatype. |
protected long |
getNextM4SequenceValue(java.sql.Statement stmt)
|
long |
getNumberOfMonthsBetween(java.lang.String dbObjectName,
java.lang.String firstValue,
java.lang.String secondValue)
Abstract method to be implemented by the subclasses. |
java.lang.String |
getPowerExpression(java.lang.String base,
java.lang.String exponent)
Abstract method to be implemented by the subclasses. |
java.util.Collection |
getPrimaryKeyColumnNames(java.lang.String dbObjectName)
Returns a Collection with the names of the DB columns that belong to the given table or view and form its primary key, if such a key is declared by SQL constraints in the DB. |
java.lang.String |
getRoundToDecimalPlacesExpression()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getSelectStringAllColumnsForDbObject(java.lang.String dbObjectName)
Abstract method to be implemented by the subclasses. |
java.lang.String |
getSelectStringAllTables()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getSelectStringAllViews()
Abstract method to be implemented by the subclasses. |
java.lang.String |
getSelectStringColumnDataTypes(java.lang.String dbObjectName,
java.lang.String owner,
java.lang.String columnName)
This method returns the DBMS-dependent SQL command that returns the name of the datatype of the given column in the given table or view (which is owned by the given owner). |
java.lang.String |
getSelectStringDistribValuesTimeColumn(java.lang.String colSql,
java.lang.String tableName,
java.lang.String distribBase)
Returns the SQL string that selects distribution values from the given column (given by its name and the name of its table or view). |
java.lang.String |
getTableOrViewType(java.lang.String dbObjectName)
Returns one of the TYPE_... constants in the class edu.udo.cs.miningmart.m4.Columnset, or null if the given String is neither a table or view. |
java.util.Map |
getTablesReferencedBy(java.lang.String dbObjectName)
Returns a Map that maps every column of the given table to the name of the table that it references as a foreign key, or to null if the column does not act as a foreign key. |
java.util.Map |
getTablesReferringTo(java.lang.String dbObjectName)
Returns a Map that maps every column of the given table to a list with names of the tables that refer to it as a foreign key, or to null if no other column refers to it. |
java.lang.String |
getTestQuery()
|
java.lang.String |
getUniqueRowIdentifier()
WARNING: the unique row identifier works only for tables with a single primary key column of type integer! |
protected void |
registerJDBC_Driver()
Implements the superclass method so that the correct JDBC driver for MySQL is used. |
protected void |
switchAutocommitOff(java.sql.Connection con)
Since the transaction mechanism may be different for different DBMS, use this method to implement the Autocommit handling. |
boolean |
tableExists(java.lang.String tableName)
Returns TRUE if a table (not a view) with the given name exists in the database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String MYSQL_TYPE_NUMBER
public static final java.lang.String MYSQL_TYPE_INTEGER
public static final java.lang.String MYSQL_TYPE_STRING
public static final java.lang.String MYSQL_TYPE_CHAR
public static final java.lang.String MYSQL_TYPE_DATE
public static final java.lang.String MYSQL_TYPE_TIME
public static final java.lang.String MYSQL_TYPE_TIMESTAMP
public static final java.lang.String MYSQL_TYPE_TEXT
| Constructor Detail |
|---|
public DbCoreMysql(java.lang.String url,
java.lang.String dbName,
java.lang.String user,
java.lang.String passwd,
M4InterfaceContext cal,
boolean isM4Schema)
throws java.sql.SQLException
url - Prefix of the database urldbName - name of the databaseuser - name of the database userpasswd - password for the database usercal - the CompilerAccessLogic of the current thread. It is just needed
in order to reach the appropriate Print-object for writing debug messagesisM4Schema - is true iff the connection refers to the M4 schema. Useful
to decide whether triggers need to be switched off etc.
java.sql.SQLExceptionedu.udo.cs.miningmart.m4.core.utils.DbCore#DbCore(String, String, String, String, CompilerAccessLogic, boolean)| Method Detail |
|---|
protected void registerJDBC_Driver()
throws java.sql.SQLException
registerJDBC_Driver in class DbCorejava.sql.SQLExceptionpublic short getDbms()
getDbms in class DbCore
protected void switchAutocommitOff(java.sql.Connection con)
throws java.sql.SQLException
DbCore
switchAutocommitOff in class DbCorejava.sql.SQLExceptionDbCore#switchAutocommitOff()
protected long getNextM4SequenceValue(java.sql.Statement stmt)
throws M4Exception
getNextM4SequenceValue in class DbCorestmt - the Statement to be used to execute the query
M4Exception - if for some reason the sequence does not return a valueDbCore.getNextM4SequenceValue(Statement)public java.lang.String getSelectStringAllTables()
DbCore
getSelectStringAllTables in class DbCoreDbCorepublic java.lang.String getSelectStringAllViews()
DbCore
getSelectStringAllViews in class DbCoreDbCore
public java.lang.String getSelectStringDistribValuesTimeColumn(java.lang.String colSql,
java.lang.String tableName,
java.lang.String distribBase)
DbCore
getSelectStringDistribValuesTimeColumn in class DbCorecolSql - string that determines the column in the given table or viewtableName - name of a table or viewdistribBase - granularity of values to be returned by the query
DbCorepublic java.lang.String getSelectStringAllColumnsForDbObject(java.lang.String dbObjectName)
DbCore
getSelectStringAllColumnsForDbObject in class DbCoredbObjectName - Name of a table OR view in the business data schema
DbCore
public long getNumberOfMonthsBetween(java.lang.String dbObjectName,
java.lang.String firstValue,
java.lang.String secondValue)
throws M4Exception
DbCore
getNumberOfMonthsBetween in class DbCoreM4Exception
public boolean tableExists(java.lang.String tableName)
throws M4Exception
DbCore
tableExists in class DbCoretableName - the table name
M4Exception
public java.lang.String getSelectStringColumnDataTypes(java.lang.String dbObjectName,
java.lang.String owner,
java.lang.String columnName)
DbCore
getSelectStringColumnDataTypes in class DbCoredbObjectName - Name of a table or view in the business data schemaowner - Name of the owner of the table or view (can be null)columnName - Name of the column whose datatype is returned
DbCore
public java.util.Collection getPrimaryKeyColumnNames(java.lang.String dbObjectName)
throws java.sql.SQLException,
DbConnectionClosed
DbCore
getPrimaryKeyColumnNames in class DbCoredbObjectName - the name of the given table or view
java.sql.SQLException
DbConnectionClosedDbCore
public java.util.Map getTablesReferencedBy(java.lang.String dbObjectName)
throws java.sql.SQLException,
DbConnectionClosed
DbCore
getTablesReferencedBy in class DbCoredbObjectName - the given table name
java.sql.SQLException
DbConnectionClosedDbCore
public java.util.Map getTablesReferringTo(java.lang.String dbObjectName)
throws java.sql.SQLException,
DbConnectionClosed
DbCore
getTablesReferringTo in class DbCoredbObjectName - the given table name
java.sql.SQLException
DbConnectionClosedDbCore
public java.lang.String getTableOrViewType(java.lang.String dbObjectName)
throws java.sql.SQLException,
DbConnectionClosed
getTableOrViewType in class DbCoredbObjectName - name of a table or view
java.sql.SQLException
DbConnectionClosedpublic java.lang.String getAttributeForColumnNames()
DbCore
getAttributeForColumnNames in class DbCoreDbCorepublic java.lang.String getAttributeForColumnTypes()
DbCore
getAttributeForColumnTypes in class DbCoreDbCorepublic java.lang.String getUniqueRowIdentifier()
getUniqueRowIdentifier in class DbCoreDbCore
public java.lang.String getPowerExpression(java.lang.String base,
java.lang.String exponent)
DbCore
getPowerExpression in class DbCoreDbCorepublic java.lang.String getFloorExpression()
getFloorExpression in class DbCorepublic java.lang.String getRoundToDecimalPlacesExpression()
getRoundToDecimalPlacesExpression in class DbCorepublic java.lang.String getAliasExpressionForInnerSelects(java.lang.String aliasName)
DbCore
getAliasExpressionForInnerSelects in class DbCoreDbCore
public java.lang.String getDatatypeName(java.lang.String m4RelDatatypeName,
int size)
DbCore
getDatatypeName in class DbCorem4RelDatatypeName - name of the M4 Relational Datatypesize - A size to be returned with the datatype, if the DBMS allows that.
For example, if the M4 Relational Datatype is NUMBER and length is 10,
then the return value will be the String "NUMBER(10)"
if the DBMS is Oracle. If this length is not positive, the datatype will be returned without
a size, in the example: "NUMBER". The DBMS may not allow lengths at all, in which case
also the datatype without a size is returned.
DbCorepublic java.lang.String getM4DatatypeName(java.lang.String dbmsDatatypeName)
DbCore
getM4DatatypeName in class DbCoredbmsDatatypeName - the name of the datatype in the underlying DBMS
DbCore
public boolean dropRelation(java.lang.String tableName)
throws M4Exception
dropRelation in class DbCoretableName - the name of the table to be dropped
M4Exceptionpublic java.lang.String getTestQuery()
getTestQuery in class DbCoreString that can be used as a query to test the DB connection.
public java.lang.String createPrimaryKeyConstraint(java.lang.String tableName,
java.util.Collection pkAttributeNames,
java.lang.String dbConstraintName)
throws java.sql.SQLException,
DbConnectionClosed
createPrimaryKeyConstraint in class DbCoretableName - The table for which to add the constraintpkAttributeNames - a Collection of Strings, each
with the name of a primary key attribute (relational level)dbConstraintName - a unique name for the database constraint,
or null to use a generic name
java.sql.SQLException
DbConnectionClosed
public void createForeignKeyConstraint(java.lang.String fkTableName,
java.util.Collection fkAttributeNames,
java.lang.String pkTableName,
java.util.Collection pkAttributeNames,
java.lang.String dbConstraintName)
throws java.sql.SQLException,
DbConnectionClosed
createForeignKeyConstraint in class DbCorefkTableName - The name of the table to create the constraint for.fkAttributeNames - Collection of attribute names (relational level)
part of the fkTableName table that point to the primary key attributes
of pkTableName.pkTableName - The name of the referenced table.pkAttributeNames - Collection of attribute names that constitute the
primary key of the referenced tabledbConstraintName - unique name of the database constraint, must not be
null
java.sql.SQLException
DbConnectionClosed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||