public class CmsSetupDb
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
static java.lang.String |
SETUP_DATA_FOLDER
The folder where to read the setup data from.
|
static java.lang.String |
SETUP_FOLDER
The folder where the setup wizard is located.
|
| 构造器和说明 |
|---|
CmsSetupDb(java.lang.String basePath)
Creates a new CmsSetupDb object.
|
| 限定符和类型 | 方法和说明 |
|---|---|
java.lang.String |
checkVariables(java.lang.String db)
Returns an optional warning message if needed,
null if not. |
void |
clearErrors()
Clears the error messages stored internally.
|
void |
closeConnection()
Closes the internal connection to the database.
|
void |
createDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
Calls the create database script for the given database.
|
void |
createDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
Calls the create database script for the given database.
|
void |
createTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
Calls the create tables script for the given database.
|
void |
createTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
Calls the create tables script for the given database.
|
void |
dropDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
Calls the drop script for the given database.
|
void |
dropDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
Calls the drop script for the given database.
|
void |
dropTables(java.lang.String database)
Calls the drop tables script for the given database.
|
void |
dropTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
Calls the drop tables script for the given database.
|
void |
dropTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
Calls the drop tables script for the given database.
|
CmsSetupDBWrapper |
executeSqlStatement(java.lang.String query,
java.util.Map<java.lang.String,java.lang.String> replacer)
Creates and executes a database statement from a String returning the result set.
|
CmsSetupDBWrapper |
executeSqlStatement(java.lang.String query,
java.util.Map<java.lang.String,java.lang.String> replacer,
java.util.List<java.lang.Object> params)
Creates and executes a database statement from a String returning the result set.
|
java.sql.Connection |
getConnection()
Returns the connection.
|
java.util.List<java.lang.String> |
getErrors()
Returns a Vector of Error messages.
|
boolean |
hasTableOrColumn(java.lang.String table,
java.lang.String column)
Checks if the given table, column or combination of both is available in the database in case insensitive way.
|
boolean |
hasTableOrColumnCaseSensitive(java.lang.String table,
java.lang.String column)
Checks if the given table, column or combination of both is available in the database in a case sensitive way.
|
boolean |
noErrors()
Checks if internal errors occurred.
|
void |
setConnection(java.sql.Connection conn)
Sets a new internal connection to the database.
|
void |
setConnection(java.lang.String DbDriver,
java.lang.String DbConStr,
java.lang.String DbConStrParams,
java.lang.String DbUser,
java.lang.String DbPwd)
Creates a new internal connection to the database.
|
void |
updateDatabase(java.lang.String updateScript,
java.util.Map<java.lang.String,java.lang.String> replacers)
Calls an update script.
|
void |
updateDatabase(java.lang.String updateScript,
java.util.Map<java.lang.String,java.lang.String> replacers,
boolean abortOnError)
Calls an update script.
|
int |
updateSqlStatement(java.lang.String query,
java.util.Map<java.lang.String,java.lang.String> replacer,
java.util.List<java.lang.Object> params)
Creates and executes a database statment from a String.
|
public static final java.lang.String SETUP_DATA_FOLDER
public static final java.lang.String SETUP_FOLDER
public CmsSetupDb(java.lang.String basePath)
basePath - the location of the setup scriptspublic java.lang.String checkVariables(java.lang.String db)
null if not.db - the selected database keynull if no warningpublic void clearErrors()
public void closeConnection()
public void createDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
database - the name of the databasereplacer - the replacements to perform in the drop scriptpublic void createDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
database - the name of the databasereplacer - the replacements to perform in the drop scriptabortOnError - indicates if the script is aborted if an error occurspublic void createTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
database - the name of the databasereplacer - the replacements to perform in the drop scriptpublic void createTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
database - the name of the databasereplacer - the replacements to perform in the drop scriptabortOnError - indicates if the script is aborted if an error occurspublic void dropDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
database - the name of the databasereplacer - the replacements to perform in the drop scriptpublic void dropDatabase(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
database - the name of the databasereplacer - the replacements to perform in the drop scriptabortOnError - indicates if the script is aborted if an error occurspublic void dropTables(java.lang.String database)
database - the name of the databasepublic void dropTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer)
database - the name of the databasereplacer - the replacements to perform in the drop scriptpublic void dropTables(java.lang.String database,
java.util.Map<java.lang.String,java.lang.String> replacer,
boolean abortOnError)
database - the name of the databasereplacer - the replacements to perform in the drop scriptabortOnError - indicates if the script is aborted if an error occurspublic CmsSetupDBWrapper executeSqlStatement(java.lang.String query, java.util.Map<java.lang.String,java.lang.String> replacer) throws java.sql.SQLException
query - the query to executereplacer - the replacements to perform in the scriptjava.sql.SQLException - if something goes wrongpublic CmsSetupDBWrapper executeSqlStatement(java.lang.String query, java.util.Map<java.lang.String,java.lang.String> replacer, java.util.List<java.lang.Object> params) throws java.sql.SQLException
query - the query to executereplacer - the replacements to perform in the scriptparams - the list of parameters for the statementjava.sql.SQLException - if something goes wrongpublic java.sql.Connection getConnection()
public java.util.List<java.lang.String> getErrors()
public boolean hasTableOrColumn(java.lang.String table,
java.lang.String column)
table - the sought tablecolumn - the sought columnpublic boolean hasTableOrColumnCaseSensitive(java.lang.String table,
java.lang.String column)
table - the sought tablecolumn - the sought columnpublic boolean noErrors()
public void setConnection(java.sql.Connection conn)
conn - the connection to usepublic void setConnection(java.lang.String DbDriver,
java.lang.String DbConStr,
java.lang.String DbConStrParams,
java.lang.String DbUser,
java.lang.String DbPwd)
DbDriver - JDBC driver class nameDbConStr - JDBC connect URLDbConStrParams - JDBC connect URL params, or nullDbUser - JDBC database userDbPwd - JDBC database passwordpublic void updateDatabase(java.lang.String updateScript,
java.util.Map<java.lang.String,java.lang.String> replacers)
updateScript - the update script codereplacers - the replacers to use in the script codepublic void updateDatabase(java.lang.String updateScript,
java.util.Map<java.lang.String,java.lang.String> replacers,
boolean abortOnError)
updateScript - the update script codereplacers - the replacers to use in the script codeabortOnError - indicates if the script is aborted if an error occurspublic int updateSqlStatement(java.lang.String query,
java.util.Map<java.lang.String,java.lang.String> replacer,
java.util.List<java.lang.Object> params)
throws java.sql.SQLException
query - the query to executereplacer - the replacements to perform in the scriptparams - the list of parameters for the statementjava.sql.SQLException - if something goes wrong