Fork me on GitHub

sql:execute

Full name:

org.codehaus.mojo:sql-maven-plugin:3.0.0:execute

Description:

Executes SQL against a database.

Attributes:

  • Requires a Maven project to be executed.
  • The goal is thread-safe and supports parallel builds.

Required Parameters

Name Type Since Description
<driver> String 1.0 Database driver classname.
User Property: driver
<forceMojoExecution> boolean - Setting this parameter to true will force the execution of this mojo, even if it would get skipped usually.
Default: false
User Property: forceOpenJpaExecution
<url> String 1.0-beta-1 Database URL.
User Property: url

Optional Parameters

Name Type Since Description
<autocommit> boolean 1.0 Set to true to execute none-transactional SQL.
Default: false
User Property: autocommit
<connectionRetryCount> int 3.0.0 Connection retry count. How many times connection is tried to be opened and validated after failure.
Default: 0
User Property: connectionRetryCount
<connectionRetryInterval> int 3.0.0 How many seconds are waited before next connection attempt.
Default: 1
User Property: connectionRetryInterval
<connectionValidationSqls> List<String> 3.0.0 List of connection validation SQLs. If the value is given, the SQL files are processed after all validation have been executed successfully. The validation SQLs can be used to verify that required tables or data exists before the SQLs are processed.
User Property: connectionValidationSqls
<delimiter> String 1.0 Set the delimiter that separates SQL statements.
Default: ;
User Property: delimiter
<delimiterType> String 1.2

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.

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


Default: normal
User Property: delimiterType
<driverProperties> String 1.0 Additional key=value pairs separated by comma to be passed into JDBC driver.
User Property: driverProperties
<enableAnonymousPassword> boolean 1.4 Ignore the password and use anonymous access. This may be useful for databases like MySQL which do not allow empty password parameters in the connection initialization.
Default: false
<enableFiltering> boolean 1.4 Set to true if you want to filter the srcFiles using system-, user- and project properties
Default: false
User Property: enableFiltering
<encoding> String 1.1 Encoding to use when reading SQL statements from a file.
Default: ${project.build.sourceEncoding}
User Property: encoding
<escapeProcessing> boolean 1.4 Argument to Statement.setEscapeProcessing If you want the driver to use regular SQL syntax then set this to false.
Default: true
User Property: escapeProcessing
<fileset> Fileset 1.0 File(s) containing SQL statements to load. Only use a Fileset if you want to use ant-like filepatterns, otherwise use srcFiles. The order is based on a matching occurrence while scanning the directory (not the order of includes!).
See also: srcFiles
<keepFormat> boolean 1.1 Keep the format of an SQL block.
Default: false
User Property: keepFormat
<onError> String 1.0 Action to perform if an error is found. Possible values are abort and continue.
Default: abort
User Property: onError
<orderFile> String 1.1 Set the order in which the SQL files will be executed. Possible values are ascending and descending. Any other value means that no sorting will be performed. Refers to fileset and srcFiles
User Property: orderFile
<outputDelimiter> String 1.4 The delimiter used to separate fields in the output when using printResultSet.
Default: ,
<outputEncoding> String 3.0.0 Encoding to use while writing queried data to a file.
Default: ${project.build.sourceEncoding}
User Property: outputEncoding
<outputFile> File 1.3 Dump the SQL execution's output to a file.
Default value is: System.out.
<password> String 1.0 Database password. If not given, it will be looked up through settings.xml's server with ${settingsKey} as key.
User Property: password
<postExecuteHookScript> File 1.6 No description.
<preExecuteHookScript> File 1.6 No description.
<printResultSet> boolean 1.3 Print SQL results.
Default: false
User Property: printResultSet
<rollbackTransactions> boolean 3.0.0 Set to true to execute immediately rollback transactional SQL.
Default: false
User Property: rollbackTransactions
<settingsKey> String 1.0 Server's id in settings.xml to look up username and password. Defaults to ${url} if not given.
User Property: settingsKey
<showFooter> boolean - Print footer value, informing on the number of rows
Default: true
User Property: showFooter
<showHeaders> boolean - Print header columns.
Default: true
User Property: showheaders
<skip> boolean 1.0 When true, skip the execution.
Default: false
<skipMissingFiles> boolean - Skip missing files defined by setSrcFiles(java.io.File[]). This behavior allows to define a full fledged list of all sql files in a single pom.xml without failing if used by modules for which some sql files are not available on the classpath.
Default: false
User Property: skipMissingFiles
<skipOnConnectionError> boolean 1.1 Skip execution when there is an error obtaining a connection. This is a special case to support databases, such as embedded Derby, that can shutdown the database via the URL (i.e. shutdown=true).
Default: false
User Property: skipOnConnectionError
<sqlCommand> String 1.0 SQL input commands separated by ${delimiter}.
User Property: sqlCommand
<srcFiles> File[] 1.0 List of files containing SQL statements to load.
See also: fileset
<username> String 1.0 Database username. If not given, it will be looked up through settings.xml's server with ${settingsKey} as key.
User Property: username

Parameter Details

<autocommit>

Set to true to execute none-transactional SQL.
  • Type: boolean
  • Since: 1.0
  • Required: No
  • User Property: autocommit
  • Default: false

<connectionRetryCount>

Connection retry count. How many times connection is tried to be opened and validated after failure.
  • Type: int
  • Since: 3.0.0
  • Required: No
  • User Property: connectionRetryCount
  • Default: 0

<connectionRetryInterval>

How many seconds are waited before next connection attempt.
  • Type: int
  • Since: 3.0.0
  • Required: No
  • User Property: connectionRetryInterval
  • Default: 1

<connectionValidationSqls>

List of connection validation SQLs. If the value is given, the SQL files are processed after all validation have been executed successfully. The validation SQLs can be used to verify that required tables or data exists before the SQLs are processed.
  • Type: java.util.List<java.lang.String>
  • Since: 3.0.0
  • Required: No
  • User Property: connectionValidationSqls

<delimiter>

Set the delimiter that separates SQL statements.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: delimiter
  • Default: ;

<delimiterType>

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.

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

  • Type: java.lang.String
  • Since: 1.2
  • Required: No
  • User Property: delimiterType
  • Default: normal

<driver>

Database driver classname.
  • Type: java.lang.String
  • Since: 1.0
  • Required: Yes
  • User Property: driver

<driverProperties>

Additional key=value pairs separated by comma to be passed into JDBC driver.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: driverProperties

<enableAnonymousPassword>

Ignore the password and use anonymous access. This may be useful for databases like MySQL which do not allow empty password parameters in the connection initialization.
  • Type: boolean
  • Since: 1.4
  • Required: No
  • Default: false

<enableFiltering>

Set to true if you want to filter the srcFiles using system-, user- and project properties
  • Type: boolean
  • Since: 1.4
  • Required: No
  • User Property: enableFiltering
  • Default: false

<encoding>

Encoding to use when reading SQL statements from a file.
  • Type: java.lang.String
  • Since: 1.1
  • Required: No
  • User Property: encoding
  • Default: ${project.build.sourceEncoding}

<escapeProcessing>

Argument to Statement.setEscapeProcessing If you want the driver to use regular SQL syntax then set this to false.
  • Type: boolean
  • Since: 1.4
  • Required: No
  • User Property: escapeProcessing
  • Default: true

<fileset>

File(s) containing SQL statements to load. Only use a Fileset if you want to use ant-like filepatterns, otherwise use srcFiles. The order is based on a matching occurrence while scanning the directory (not the order of includes!).
See also: srcFiles
  • Type: org.codehaus.mojo.sql.Fileset
  • Since: 1.0
  • Required: No

<forceMojoExecution>

Setting this parameter to true will force the execution of this mojo, even if it would get skipped usually.
  • Type: boolean
  • Required: Yes
  • User Property: forceOpenJpaExecution
  • Default: false

<keepFormat>

Keep the format of an SQL block.
  • Type: boolean
  • Since: 1.1
  • Required: No
  • User Property: keepFormat
  • Default: false

<onError>

Action to perform if an error is found. Possible values are abort and continue.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: onError
  • Default: abort

<orderFile>

Set the order in which the SQL files will be executed. Possible values are ascending and descending. Any other value means that no sorting will be performed. Refers to fileset and srcFiles
  • Type: java.lang.String
  • Since: 1.1
  • Required: No
  • User Property: orderFile

<outputDelimiter>

The delimiter used to separate fields in the output when using printResultSet.
  • Type: java.lang.String
  • Since: 1.4
  • Required: No
  • Default: ,

<outputEncoding>

Encoding to use while writing queried data to a file.
  • Type: java.lang.String
  • Since: 3.0.0
  • Required: No
  • User Property: outputEncoding
  • Default: ${project.build.sourceEncoding}

<outputFile>

Dump the SQL execution's output to a file.
Default value is: System.out.
  • Type: java.io.File
  • Since: 1.3
  • Required: No

<password>

Database password. If not given, it will be looked up through settings.xml's server with ${settingsKey} as key.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: password

<postExecuteHookScript>

No description.
  • Type: java.io.File
  • Since: 1.6
  • Required: No

<preExecuteHookScript>

No description.
  • Type: java.io.File
  • Since: 1.6
  • Required: No

<printResultSet>

Print SQL results.
  • Type: boolean
  • Since: 1.3
  • Required: No
  • User Property: printResultSet
  • Default: false

<rollbackTransactions>

Set to true to execute immediately rollback transactional SQL.
  • Type: boolean
  • Since: 3.0.0
  • Required: No
  • User Property: rollbackTransactions
  • Default: false

<settingsKey>

Server's id in settings.xml to look up username and password. Defaults to ${url} if not given.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: settingsKey

<showFooter>

Print footer value, informing on the number of rows
  • Type: boolean
  • Required: No
  • User Property: showFooter
  • Default: true

<showHeaders>

Print header columns.
  • Type: boolean
  • Required: No
  • User Property: showheaders
  • Default: true

<skip>

When true, skip the execution.
  • Type: boolean
  • Since: 1.0
  • Required: No
  • Default: false

<skipMissingFiles>

Skip missing files defined by setSrcFiles(java.io.File[]). This behavior allows to define a full fledged list of all sql files in a single pom.xml without failing if used by modules for which some sql files are not available on the classpath.
  • Type: boolean
  • Required: No
  • User Property: skipMissingFiles
  • Default: false

<skipOnConnectionError>

Skip execution when there is an error obtaining a connection. This is a special case to support databases, such as embedded Derby, that can shutdown the database via the URL (i.e. shutdown=true).
  • Type: boolean
  • Since: 1.1
  • Required: No
  • User Property: skipOnConnectionError
  • Default: false

<sqlCommand>

SQL input commands separated by ${delimiter}.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: sqlCommand

<srcFiles>

List of files containing SQL statements to load.
See also: fileset
  • Type: java.io.File[]
  • Since: 1.0
  • Required: No

<url>

Database URL.
  • Type: java.lang.String
  • Since: 1.0-beta-1
  • Required: Yes
  • User Property: url

<username>

Database username. If not given, it will be looked up through settings.xml's server with ${settingsKey} as key.
  • Type: java.lang.String
  • Since: 1.0
  • Required: No
  • User Property: username