|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.maven.plugin.AbstractMojo org.apache.torque.mojo.BaseMojo org.apache.torque.mojo.AbstractSQLExecutorMojo
public abstract class AbstractSQLExecutorMojo
Abstract mojo for making use of SQLExecutor
Field Summary | |
---|---|
(package private) boolean |
append
If writing output to a file, append to an existing file or overwrite it? |
(package private) boolean |
autocommit
Set to true to execute non-transactional SQL. |
(package private) Connection |
conn
Database connection |
(package private) ConnectionHandler |
connectionHandler
|
(package private) Credentials |
credentials
The credentials to use for database access |
(package private) String |
delimiter
Set the delimiter that separates SQL statements. |
(package private) String |
delimiterType
The delimiter type takes two values - "normal" and "row". |
(package private) String |
driver
Database driver classname. |
static String |
DRIVER_INFO_PROPERTIES_PASSWORD
|
static String |
DRIVER_INFO_PROPERTIES_USER
|
(package private) String |
driverProperties
Additional key=value pairs separated by a comma to be passed to JDBC driver. |
(package private) boolean |
enableAnonymousPassword
Ignore the password and use anonymous access. |
(package private) boolean |
enableAnonymousUsername
Ignore the username and use anonymous access. |
(package private) boolean |
escapeProcessing
Argument to Statement.setEscapeProcessing If you want the driver to use regular SQL syntax then set this to false. |
static String |
FILE_SORTING_ASC
Call #setOrder(String) with this value to sort in ascendant order the sql files. |
static String |
FILE_SORTING_DSC
Call #setOrder(String) with this value to sort in descendant order the sql files. |
(package private) org.apache.maven.shared.filtering.MavenFileFilter |
fileFilter
|
(package private) JDBCUtils |
jdbcUtils
|
(package private) boolean |
keepFormat
Keep the format of an SQL block. |
(package private) String |
onError
Action to perform if an error is found. |
(package private) String |
password
Database password. |
(package private) Platform |
platform
|
(package private) String |
settingsKey
The id of the server in settings.xml containing the username/password to use. |
(package private) boolean |
showheaders
Print header columns. |
(package private) boolean |
showPassword
If set to true the password being used to connect to the database will be displayed in log messages. |
(package private) boolean |
skipOnConnectionError
Skip execution if there is an error obtaining a connection. |
(package private) String |
sqlCommand
SQL input commands separated by ${delimiter} . |
(package private) File[] |
srcFiles
List of files containing SQL statements to load. |
(package private) int |
successfulStatements
number of successful executed statements |
(package private) String |
targetDatabase
The type of database we are targeting (eg oracle, mysql). |
(package private) int |
totalStatements
number of total executed statements |
(package private) Vector<Transaction> |
transactions
SQL transactions to perform |
(package private) String |
url
Database URL. |
(package private) String |
username
Database username. |
(package private) Utils |
utils
|
Fields inherited from class org.apache.torque.mojo.BaseMojo |
---|
FS, SKIP_PACKAGING_TYPE |
Fields inherited from interface org.apache.maven.plugin.Mojo |
---|
ROLE |
Constructor Summary | |
---|---|
AbstractSQLExecutorMojo()
|
Method Summary | |
---|---|
void |
addText(String sql)
Set an inline SQL command to execute. |
protected void |
configureTransactions()
|
protected String |
convertNullToEmpty(String s)
|
void |
executeMojo()
Validate our configuration and execute SQL as appropriate |
Connection |
getConn()
|
protected Connection |
getConnection()
Creates a new Connection as using the driver, url, userid and password specified. |
protected Properties |
getContextProperties()
|
Credentials |
getCredentials()
|
String |
getDelimiter()
|
String |
getDelimiterType()
|
protected String |
getDisplayPassword(String password)
|
String |
getDriver()
|
protected Properties |
getDriverProperties()
parse driverProperties into Properties set |
org.apache.maven.shared.filtering.MavenFileFilter |
getFileFilter()
|
protected ConnectionHandler |
getNewConnectionHandler()
|
protected Credentials |
getNewCredentials()
|
String |
getOnError()
|
String |
getPassword()
|
protected org.apache.maven.settings.Server |
getServerFromSettingsKey()
|
String |
getSettingsKey()
|
String |
getSqlCommand()
|
protected SQLExecutor |
getSqlExecutor()
|
File[] |
getSrcFiles()
|
int |
getSuccessfulStatements()
Number of SQL statements executed so far that caused errors. |
String |
getTargetDatabase()
|
int |
getTotalStatements()
Number of SQL statements executed so far, including the ones that caused errors. |
Vector<Transaction> |
getTransactions()
|
protected String |
getUpdatedPassword(org.apache.maven.settings.Server server,
String password)
|
protected String |
getUpdatedUsername(org.apache.maven.settings.Server server,
String username)
|
String |
getUrl()
|
String |
getUsername()
|
boolean |
isAppend()
|
boolean |
isAutocommit()
|
boolean |
isEnableAnonymousPassword()
|
boolean |
isEscapeProcessing()
|
boolean |
isKeepFormat()
|
protected boolean |
isNullOrEmpty(Collection<?> c)
|
boolean |
isShowheaders()
|
boolean |
isShowPassword()
|
boolean |
isSkipOnConnectionError()
|
void |
setAppend(boolean append)
whether output should be appended to or overwrite an existing file. |
void |
setAutocommit(boolean autocommit)
|
void |
setConn(Connection conn)
|
void |
setCredentials(Credentials credentials)
|
void |
setDelimiter(String delimiter)
Set the delimiter that separates SQL statements. |
void |
setDelimiterType(String delimiterType)
Set the delimiter type: "normal" or "row" (default "normal"). |
void |
setDriver(String driver)
|
void |
setDriverProperties(String driverProperties)
|
void |
setEnableAnonymousPassword(boolean enableAnonymousPassword)
|
void |
setEscapeProcessing(boolean enable)
Set escape processing for statements. |
void |
setFileFilter(org.apache.maven.shared.filtering.MavenFileFilter filter)
|
void |
setKeepFormat(boolean keepformat)
whether or not format should be preserved. |
void |
setOnError(String action)
|
void |
setPassword(String password)
|
void |
setSettingsKey(String key)
|
void |
setShowheaders(boolean showheaders)
Print headers for result sets from the statements; optional, default true. |
void |
setShowPassword(boolean showPassword)
|
void |
setSkipOnConnectionError(boolean skipOnConnectionError)
|
void |
setSqlCommand(String sqlCommand)
|
void |
setSrcFiles(File[] files)
|
void |
setSuccessfulStatements(int successfulStatements)
|
void |
setTargetDatabase(String targetDatabase)
|
void |
setTotalStatements(int totalStatements)
|
void |
setTransactions(Vector<Transaction> transactions)
|
void |
setUrl(String url)
|
void |
setUsername(String username)
|
protected void |
updateConfiguration()
Attempt to automatically detect the correct JDBC driver and database type (oracle, mysql, h2, derby, etc) given a JDBC url |
protected void |
updateCredentials(Credentials credentials)
Load username/password from settings.xml if user has not set them in JVM properties |
protected void |
validateConfiguration()
Validate that some essential configuration items are present |
protected void |
validateCredentials(Credentials credentials)
|
protected void |
validateCredentials(Credentials credentials,
boolean anonymousAccessAllowed,
String validationFailureMessage)
|
Methods inherited from class org.apache.torque.mojo.BaseMojo |
---|
afterExecution, beforeExecution, execute, getEncoding, getMavenSession, getProject, getSettings, isForceMojoExecution, isSkip, isStartMavenLogger, setEncoding, setForceMojoExecution, setMavenSession, setProject, setSettings, setSkip, setStartMavenLogger, skipMojo |
Methods inherited from class org.apache.maven.plugin.AbstractMojo |
---|
getLog, getPluginContext, setLog, setPluginContext |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
Utils utils
JDBCUtils jdbcUtils
ConnectionHandler connectionHandler
Platform platform
public static final String DRIVER_INFO_PROPERTIES_USER
public static final String DRIVER_INFO_PROPERTIES_PASSWORD
public static final String FILE_SORTING_ASC
#setOrder(String)
with this value to sort in ascendant order the sql files.
public static final String FILE_SORTING_DSC
#setOrder(String)
with this value to sort in descendant order the sql files.
String targetDatabase
url
is supplied as the
database type will be automatically detected based on the url
. If targetDatabase is explicitly
supplied it will override the type selected by the automatic detection logic.
String username
settings.xml
's server with
${settingsKey}
as key.
String password
settings.xml
's server with
${settingsKey}
as key.
boolean enableAnonymousPassword
boolean enableAnonymousUsername
String driverProperties
boolean showPassword
String settingsKey
boolean skipOnConnectionError
String sqlCommand
${delimiter}
.
File[] srcFiles
String url
String driver
url
in almost all cases (works for Oracle, MySQL, Derby, PostGresSQL, DB2, H2, HSQL, SQL Server). If
a driver is explicitly supplied, it will be used in place of the JDBC driver the automatic detection logic would
have chosen.
boolean autocommit
true
to execute non-transactional SQL.
String onError
abort
and continue
.
String delimiter
String delimiterType
boolean keepFormat
boolean showheaders
boolean append
boolean escapeProcessing
int successfulStatements
int totalStatements
Connection conn
Vector<Transaction> transactions
org.apache.maven.shared.filtering.MavenFileFilter fileFilter
Credentials credentials
Constructor Detail |
---|
public AbstractSQLExecutorMojo()
Method Detail |
---|
protected void configureTransactions() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected Properties getContextProperties()
protected Credentials getNewCredentials()
protected ConnectionHandler getNewConnectionHandler() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public void executeMojo() throws org.apache.maven.plugin.MojoExecutionException
executeMojo
in class BaseMojo
org.apache.maven.plugin.MojoExecutionException
public void addText(String sql)
sql
- the sql statement to addpublic void setDelimiter(String delimiter)
delimiter
- the new delimiterpublic void setDelimiterType(String delimiterType)
delimiterType
- the new delimiterTypepublic void setShowheaders(boolean showheaders)
showheaders
- true
to show the headers, otherwise false
public void setAppend(boolean append)
append
- true
to append, otherwise false
to overwritepublic void setKeepFormat(boolean keepformat)
keepformat
- The keepformat to setpublic void setEscapeProcessing(boolean enable)
enable
- true
to escape, otherwiser false
protected SQLExecutor getSqlExecutor() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void updateConfiguration() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void validateConfiguration() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void validateCredentials(Credentials credentials, boolean anonymousAccessAllowed, String validationFailureMessage) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected void validateCredentials(Credentials credentials) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
protected boolean isNullOrEmpty(Collection<?> c)
protected String convertNullToEmpty(String s)
protected void updateCredentials(Credentials credentials)
org.apache.maven.plugin.MojoExecutionException
protected org.apache.maven.settings.Server getServerFromSettingsKey()
protected String getUpdatedPassword(org.apache.maven.settings.Server server, String password)
protected String getDisplayPassword(String password)
protected String getUpdatedUsername(org.apache.maven.settings.Server server, String username)
protected Connection getConnection() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
- if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load.
SQLException
- if there is problem getting connection with valid urlprotected Properties getDriverProperties() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
public String getUsername()
public void setUsername(String username)
public String getPassword()
public void setPassword(String password)
public String getUrl()
public void setUrl(String url)
public String getDriver()
public void setDriver(String driver)
public void setAutocommit(boolean autocommit)
public File[] getSrcFiles()
public void setSrcFiles(File[] files)
public int getSuccessfulStatements()
public int getTotalStatements()
public String getOnError()
public void setOnError(String action)
public void setSettingsKey(String key)
public void setDriverProperties(String driverProperties)
public String getSqlCommand()
public void setSqlCommand(String sqlCommand)
public Vector<Transaction> getTransactions()
public void setTransactions(Vector<Transaction> transactions)
public void setFileFilter(org.apache.maven.shared.filtering.MavenFileFilter filter)
public String getTargetDatabase()
public void setTargetDatabase(String targetDatabase)
public Connection getConn()
public void setConn(Connection conn)
public String getDelimiter()
public String getDelimiterType()
public boolean isKeepFormat()
public boolean isShowheaders()
public boolean isAppend()
public boolean isEscapeProcessing()
public boolean isSkipOnConnectionError()
public void setSkipOnConnectionError(boolean skipOnConnectionError)
public org.apache.maven.shared.filtering.MavenFileFilter getFileFilter()
public boolean isShowPassword()
public void setShowPassword(boolean showPassword)
public boolean isEnableAnonymousPassword()
public void setEnableAnonymousPassword(boolean enableAnonymousPassword)
public String getSettingsKey()
public boolean isAutocommit()
public void setSuccessfulStatements(int successfulStatements)
public void setTotalStatements(int totalStatements)
public void setCredentials(Credentials credentials)
public Credentials getCredentials()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |