com.liferay.portal.dao.db
Class BaseDB

java.lang.Object
  extended by com.liferay.portal.dao.db.BaseDB
All Implemented Interfaces:
com.liferay.portal.kernel.dao.db.DB
Direct Known Subclasses:
DB2DB, DerbyDB, FirebirdDB, HypersonicDB, InformixDB, IngresDB, MySQLDB, OracleDB, PostgreSQLDB, SAPDB, SQLServerDB, SybaseDB

public abstract class BaseDB
extends java.lang.Object
implements com.liferay.portal.kernel.dao.db.DB

View Source

Author:
Alexander Chow, Ganesh Ram, Brian Wing Shun Chan

Field Summary
protected static java.lang.String ALTER_COLUMN_NAME
           
protected static java.lang.String ALTER_COLUMN_TYPE
           
protected static java.lang.String DROP_INDEX
           
protected static java.lang.String DROP_PRIMARY_KEY
           
protected static java.lang.String[] REWORD_TEMPLATE
           
protected static java.lang.String[] TEMPLATE
           
 
Fields inherited from interface com.liferay.portal.kernel.dao.db.DB
MINIMAL, POPULATED, SHARDED, TYPE_ALL, TYPE_DB2, TYPE_DERBY, TYPE_FIREBIRD, TYPE_HYPERSONIC, TYPE_INFORMIX, TYPE_INGRES, TYPE_INTERBASE, TYPE_JDATASTORE, TYPE_MYSQL, TYPE_ORACLE, TYPE_POSTGRESQL, TYPE_SAP, TYPE_SQLSERVER, TYPE_SYBASE
 
Constructor Summary
protected BaseDB(java.lang.String type)
           
 
Method Summary
protected  void addIndexes(java.lang.String indexesSQL, java.util.Set<java.lang.String> validIndexNames)
           
protected  java.lang.String[] buildColumnNameTokens(java.lang.String line)
           
protected  java.lang.String[] buildColumnTypeTokens(java.lang.String line)
           
 void buildCreateFile(java.lang.String sqlDir, java.lang.String databaseName)
           
 void buildCreateFile(java.lang.String sqlDir, java.lang.String databaseName, int population)
           
protected abstract  java.lang.String buildCreateFileContent(java.lang.String sqlDir, java.lang.String databaseName, int population)
           
abstract  java.lang.String buildSQL(java.lang.String template)
           
 void buildSQLFile(java.lang.String sqlDir, java.lang.String fileName)
           
protected  java.lang.String buildTemplate(java.lang.String sqlDir, java.lang.String fileName)
           
protected  java.lang.String convertTimestamp(java.lang.String data)
           
protected  java.util.Set<java.lang.String> dropIndexes(java.lang.String tablesSQL, java.lang.String indexesSQL, java.lang.String indexesProperties, java.util.List<com.liferay.portal.kernel.dao.db.Index> indexes)
           
protected  java.lang.String evaluateVM(java.lang.String template)
           
 java.util.List<com.liferay.portal.kernel.dao.db.Index> getIndexes()
           
protected abstract  java.lang.String getServerName()
           
protected  java.lang.String getSuffix(int type)
           
protected abstract  java.lang.String[] getTemplate()
           
 java.lang.String getTemplateFalse()
           
 java.lang.String getTemplateTrue()
           
 java.lang.String getType()
           
 long increment()
           
 boolean isSupportsAlterColumnName()
           
 boolean isSupportsAlterColumnType()
           
 boolean isSupportsDateMilliseconds()
           
 boolean isSupportsScrollableResults()
           
 boolean isSupportsStringCaseSensitiveQuery()
           
 boolean isSupportsUpdateWithInnerJoin()
           
protected  java.lang.String readSQL(java.lang.String fileName, java.lang.String comments, java.lang.String eol)
           
protected  java.lang.String removeBooleanIndexes(java.lang.String sqlDir, java.lang.String data)
           
protected  java.lang.String removeInserts(java.lang.String data)
           
protected  java.lang.String removeLongInserts(java.lang.String data)
           
protected  java.lang.String removeNull(java.lang.String content)
           
protected  java.lang.String replaceTemplate(java.lang.String template, java.lang.String[] actual)
           
protected abstract  java.lang.String reword(java.lang.String data)
           
 void runSQL(java.sql.Connection con, java.lang.String sql)
           
 void runSQL(java.sql.Connection con, java.lang.String[] sqls)
           
 void runSQL(java.lang.String sql)
           
 void runSQL(java.lang.String[] sqls)
           
 void runSQLTemplate(java.lang.String path)
           
 void runSQLTemplate(java.lang.String path, boolean failOnError)
           
 void runSQLTemplateString(java.lang.String template, boolean evaluate, boolean failOnError)
           
 void setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery)
           
 void updateIndexes(java.lang.String tablesSQL, java.lang.String indexesSQL, java.lang.String indexesProperties, boolean dropIndexes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALTER_COLUMN_TYPE

protected static java.lang.String ALTER_COLUMN_TYPE

ALTER_COLUMN_NAME

protected static java.lang.String ALTER_COLUMN_NAME

DROP_INDEX

protected static java.lang.String DROP_INDEX

DROP_PRIMARY_KEY

protected static java.lang.String DROP_PRIMARY_KEY

REWORD_TEMPLATE

protected static java.lang.String[] REWORD_TEMPLATE

TEMPLATE

protected static java.lang.String[] TEMPLATE
Constructor Detail

BaseDB

protected BaseDB(java.lang.String type)
Method Detail

buildCreateFile

public void buildCreateFile(java.lang.String sqlDir,
                            java.lang.String databaseName)
                     throws java.io.IOException
Specified by:
buildCreateFile in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException

buildCreateFile

public void buildCreateFile(java.lang.String sqlDir,
                            java.lang.String databaseName,
                            int population)
                     throws java.io.IOException
Specified by:
buildCreateFile in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException

buildSQL

public abstract java.lang.String buildSQL(java.lang.String template)
                                   throws java.io.IOException
Specified by:
buildSQL in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException

buildSQLFile

public void buildSQLFile(java.lang.String sqlDir,
                         java.lang.String fileName)
                  throws java.io.IOException
Specified by:
buildSQLFile in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException

getIndexes

public java.util.List<com.liferay.portal.kernel.dao.db.Index> getIndexes()
                                                                  throws java.sql.SQLException
Specified by:
getIndexes in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.sql.SQLException

getTemplateFalse

public java.lang.String getTemplateFalse()
Specified by:
getTemplateFalse in interface com.liferay.portal.kernel.dao.db.DB

getTemplateTrue

public java.lang.String getTemplateTrue()
Specified by:
getTemplateTrue in interface com.liferay.portal.kernel.dao.db.DB

getType

public java.lang.String getType()
Specified by:
getType in interface com.liferay.portal.kernel.dao.db.DB

increment

public long increment()
               throws com.liferay.portal.kernel.exception.SystemException
Specified by:
increment in interface com.liferay.portal.kernel.dao.db.DB
Throws:
com.liferay.portal.kernel.exception.SystemException

isSupportsAlterColumnName

public boolean isSupportsAlterColumnName()
Specified by:
isSupportsAlterColumnName in interface com.liferay.portal.kernel.dao.db.DB

isSupportsAlterColumnType

public boolean isSupportsAlterColumnType()
Specified by:
isSupportsAlterColumnType in interface com.liferay.portal.kernel.dao.db.DB

isSupportsDateMilliseconds

public boolean isSupportsDateMilliseconds()
Specified by:
isSupportsDateMilliseconds in interface com.liferay.portal.kernel.dao.db.DB

isSupportsScrollableResults

public boolean isSupportsScrollableResults()
Specified by:
isSupportsScrollableResults in interface com.liferay.portal.kernel.dao.db.DB

isSupportsStringCaseSensitiveQuery

public boolean isSupportsStringCaseSensitiveQuery()
Specified by:
isSupportsStringCaseSensitiveQuery in interface com.liferay.portal.kernel.dao.db.DB

isSupportsUpdateWithInnerJoin

public boolean isSupportsUpdateWithInnerJoin()
Specified by:
isSupportsUpdateWithInnerJoin in interface com.liferay.portal.kernel.dao.db.DB

runSQL

public void runSQL(java.lang.String sql)
            throws java.io.IOException,
                   java.sql.SQLException
Specified by:
runSQL in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
java.sql.SQLException

runSQL

public void runSQL(java.sql.Connection con,
                   java.lang.String sql)
            throws java.io.IOException,
                   java.sql.SQLException
Specified by:
runSQL in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
java.sql.SQLException

runSQL

public void runSQL(java.lang.String[] sqls)
            throws java.io.IOException,
                   java.sql.SQLException
Specified by:
runSQL in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
java.sql.SQLException

runSQL

public void runSQL(java.sql.Connection con,
                   java.lang.String[] sqls)
            throws java.io.IOException,
                   java.sql.SQLException
Specified by:
runSQL in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
java.sql.SQLException

runSQLTemplate

public void runSQLTemplate(java.lang.String path)
                    throws java.io.IOException,
                           javax.naming.NamingException,
                           java.sql.SQLException
Specified by:
runSQLTemplate in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
javax.naming.NamingException
java.sql.SQLException

runSQLTemplate

public void runSQLTemplate(java.lang.String path,
                           boolean failOnError)
                    throws java.io.IOException,
                           javax.naming.NamingException,
                           java.sql.SQLException
Specified by:
runSQLTemplate in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
javax.naming.NamingException
java.sql.SQLException

runSQLTemplateString

public void runSQLTemplateString(java.lang.String template,
                                 boolean evaluate,
                                 boolean failOnError)
                          throws java.io.IOException,
                                 javax.naming.NamingException,
                                 java.sql.SQLException
Specified by:
runSQLTemplateString in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
javax.naming.NamingException
java.sql.SQLException

setSupportsStringCaseSensitiveQuery

public void setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery)
Specified by:
setSupportsStringCaseSensitiveQuery in interface com.liferay.portal.kernel.dao.db.DB

updateIndexes

public void updateIndexes(java.lang.String tablesSQL,
                          java.lang.String indexesSQL,
                          java.lang.String indexesProperties,
                          boolean dropIndexes)
                   throws java.io.IOException,
                          java.sql.SQLException
Specified by:
updateIndexes in interface com.liferay.portal.kernel.dao.db.DB
Throws:
java.io.IOException
java.sql.SQLException

addIndexes

protected void addIndexes(java.lang.String indexesSQL,
                          java.util.Set<java.lang.String> validIndexNames)
                   throws java.io.IOException
Throws:
java.io.IOException

buildCreateFileContent

protected abstract java.lang.String buildCreateFileContent(java.lang.String sqlDir,
                                                           java.lang.String databaseName,
                                                           int population)
                                                    throws java.io.IOException
Throws:
java.io.IOException

buildColumnNameTokens

protected java.lang.String[] buildColumnNameTokens(java.lang.String line)

buildColumnTypeTokens

protected java.lang.String[] buildColumnTypeTokens(java.lang.String line)

buildTemplate

protected java.lang.String buildTemplate(java.lang.String sqlDir,
                                         java.lang.String fileName)
                                  throws java.io.IOException
Throws:
java.io.IOException

convertTimestamp

protected java.lang.String convertTimestamp(java.lang.String data)

dropIndexes

protected java.util.Set<java.lang.String> dropIndexes(java.lang.String tablesSQL,
                                                      java.lang.String indexesSQL,
                                                      java.lang.String indexesProperties,
                                                      java.util.List<com.liferay.portal.kernel.dao.db.Index> indexes)
                                               throws java.io.IOException,
                                                      java.sql.SQLException
Throws:
java.io.IOException
java.sql.SQLException

evaluateVM

protected java.lang.String evaluateVM(java.lang.String template)
                               throws java.lang.Exception
Throws:
java.lang.Exception

getServerName

protected abstract java.lang.String getServerName()

getSuffix

protected java.lang.String getSuffix(int type)

getTemplate

protected abstract java.lang.String[] getTemplate()

readSQL

protected java.lang.String readSQL(java.lang.String fileName,
                                   java.lang.String comments,
                                   java.lang.String eol)
                            throws java.io.IOException
Throws:
java.io.IOException

removeBooleanIndexes

protected java.lang.String removeBooleanIndexes(java.lang.String sqlDir,
                                                java.lang.String data)
                                         throws java.io.IOException
Throws:
java.io.IOException

removeInserts

protected java.lang.String removeInserts(java.lang.String data)
                                  throws java.io.IOException
Throws:
java.io.IOException

removeLongInserts

protected java.lang.String removeLongInserts(java.lang.String data)
                                      throws java.io.IOException
Throws:
java.io.IOException

removeNull

protected java.lang.String removeNull(java.lang.String content)

replaceTemplate

protected java.lang.String replaceTemplate(java.lang.String template,
                                           java.lang.String[] actual)

reword

protected abstract java.lang.String reword(java.lang.String data)
                                    throws java.io.IOException
Throws:
java.io.IOException