org.codehaus.mojo.sql
Class SqlExecMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.sql.SqlExecMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

public class SqlExecMojo
extends org.apache.maven.plugin.AbstractMojo

Executes SQL against a database.


Field Summary
static java.lang.String FILE_SORTING_ASC
          Call setOrderFile(String) with this value to sort in ascendant order the sql files.
static java.lang.String FILE_SORTING_DSC
          Call setOrderFile(String) with this value to sort in descendant order the sql files.
static java.lang.String ON_ERROR_ABORT
          Call setOnError(String) with this value to abort SQL command execution if an error is found.
static java.lang.String ON_ERROR_CONTINUE
          Call setOnError(String) with this value to continue SQL command execution if an error is found.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
SqlExecMojo()
           
 
Method Summary
 void addText(java.lang.String sql)
          Set an inline SQL command to execute.
 org.codehaus.mojo.sql.SqlExecMojo.Transaction createTransaction()
          Add a SQL transaction to execute
 void execute()
          Load the sql file and then execute it
 java.lang.String getDriver()
           
protected  java.util.Properties getDriverProperties()
          parse driverProperties into Properties set
 java.lang.String getOnError()
           
 java.lang.String getOrderFile()
           
 java.lang.String getPassword()
           
 java.lang.String getSqlCommand()
           
 java.io.File[] getSrcFiles()
           
 int getSuccessfulStatements()
          Number of SQL statements executed so far that caused errors.
 int getTotalStatements()
          Number of SQL statements executed so far, including the ones that caused errors.
 java.util.Vector getTransactions()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 boolean isEnableBlockMode()
           
 void setAppend(boolean append)
          whether output should be appended to or overwrite an existing file.
 void setDelimiter(java.lang.String delimiter)
          Set the delimiter that separates SQL statements.
 void setDelimiterType(DelimiterType delimiterType)
          Set the delimiter type: "normal" or "row" (default "normal").
 void setDriver(java.lang.String driver)
           
 void setDriverProperties(java.lang.String driverProperties)
           
 void setEnableBlockMode(boolean enableBlockMode)
           
 void setEncoding(java.lang.String encoding)
          Set the file encoding to use on the SQL files read in
 void setEscapeProcessing(boolean enable)
          Set escape processing for statements.
 void setKeepformat(boolean keepformat)
          whether or not format should be preserved.
 void setOnError(java.lang.String action)
           
 void setOrderFile(java.lang.String orderFile)
           
 void setOutput(java.io.File output)
          Set the output file;
 void setPassword(java.lang.String password)
           
 void setPrint(boolean print)
          Print result sets from the statements; optional, default false
 void setShowheaders(boolean showheaders)
          Print headers for result sets from the statements; optional, default true.
 void setSqlCommand(java.lang.String sqlCommand)
           
 void setSrcFiles(java.io.File[] files)
           
 void setTransactions(java.util.Vector transactions)
           
 void setUrl(java.lang.String url)
           
 void setUsername(java.lang.String username)
           
 
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

ON_ERROR_ABORT

public static final java.lang.String ON_ERROR_ABORT
Call setOnError(String) with this value to abort SQL command execution if an error is found.

See Also:
Constant Field Values

ON_ERROR_CONTINUE

public static final java.lang.String ON_ERROR_CONTINUE
Call setOnError(String) with this value to continue SQL command execution if an error is found.

See Also:
Constant Field Values

FILE_SORTING_ASC

public static final java.lang.String FILE_SORTING_ASC
Call setOrderFile(String) with this value to sort in ascendant order the sql files.

See Also:
Constant Field Values

FILE_SORTING_DSC

public static final java.lang.String FILE_SORTING_DSC
Call setOrderFile(String) with this value to sort in descendant order the sql files.

See Also:
Constant Field Values
Constructor Detail

SqlExecMojo

public SqlExecMojo()
Method Detail

createTransaction

public org.codehaus.mojo.sql.SqlExecMojo.Transaction createTransaction()
Add a SQL transaction to execute


addText

public void addText(java.lang.String sql)
Set an inline SQL command to execute. NB: Properties are not expanded in this text.


setEncoding

public void setEncoding(java.lang.String encoding)
Set the file encoding to use on the SQL files read in

Parameters:
encoding - the encoding to use on the files

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Set the delimiter that separates SQL statements. Defaults to ";"; optional

For example, set this to "go" and delimitertype to "ROW" for Sybase ASE or MS SQL Server.


setDelimiterType

public void setDelimiterType(DelimiterType delimiterType)
Set the delimiter type: "normal" or "row" (default "normal").

The delimiter type takes two values - normal and row. Normal means that any occurrence of the delimiter terminate the SQL command whereas with row, only a line containing just the delimiter is recognized as the end of the command.


setPrint

public void setPrint(boolean print)
Print result sets from the statements; optional, default false


setShowheaders

public void setShowheaders(boolean showheaders)
Print headers for result sets from the statements; optional, default true.


setOutput

public void setOutput(java.io.File output)
Set the output file;


setAppend

public void setAppend(boolean append)
whether output should be appended to or overwrite an existing file. Defaults to false.


setKeepformat

public void setKeepformat(boolean keepformat)
whether or not format should be preserved. Defaults to false.

Parameters:
keepformat - The keepformat to set

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
Set escape processing for statements.


execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
Load the sql file and then execute it

Throws:
org.apache.maven.plugin.MojoExecutionException

getDriverProperties

protected java.util.Properties getDriverProperties()
                                            throws org.apache.maven.plugin.MojoExecutionException
parse driverProperties into Properties set

Returns:
Throws:
org.apache.maven.plugin.MojoExecutionException

getUsername

public java.lang.String getUsername()

setUsername

public void setUsername(java.lang.String username)

getPassword

public java.lang.String getPassword()

setPassword

public void setPassword(java.lang.String password)

getUrl

public java.lang.String getUrl()

setUrl

public void setUrl(java.lang.String url)

getDriver

public java.lang.String getDriver()

setDriver

public void setDriver(java.lang.String driver)

getSrcFiles

public java.io.File[] getSrcFiles()

setSrcFiles

public void setSrcFiles(java.io.File[] files)

getOrderFile

public java.lang.String getOrderFile()

setOrderFile

public void setOrderFile(java.lang.String orderFile)

getSuccessfulStatements

public int getSuccessfulStatements()
Number of SQL statements executed so far that caused errors.

Returns:
the number

getTotalStatements

public int getTotalStatements()
Number of SQL statements executed so far, including the ones that caused errors.

Returns:
the number

getOnError

public java.lang.String getOnError()

setOnError

public void setOnError(java.lang.String action)

setDriverProperties

public void setDriverProperties(java.lang.String driverProperties)

isEnableBlockMode

public boolean isEnableBlockMode()

setEnableBlockMode

public void setEnableBlockMode(boolean enableBlockMode)

getSqlCommand

public java.lang.String getSqlCommand()

setSqlCommand

public void setSqlCommand(java.lang.String sqlCommand)

getTransactions

public java.util.Vector getTransactions()

setTransactions

public void setTransactions(java.util.Vector transactions)


Copyright © 2006-2009. All Rights Reserved.