I use sql-maven-plugin to execute some MySQL scripts in multiple databases. I would like to deploy the same SQL script, tables, data, triggers, events, and stored procedures.
I have a problem with line separator because for INSERT or CREATE I use ; but for my triggers I need, for example, change the delimiter to DELIMITER // .
I know that the plugin allows you to change the separator, but it is applicable for all scripts, I want to change the separator only for part of a unique script.
This is my maven configuration:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>sql-maven-plugin</artifactId> <version>1.5</version> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.21</version> </dependency> </dependencies> <configuration> <driver>com.mysql.jdbc.Driver</driver> <username>${db.user}</username> <password>${db.passwd}</password> <encoding>UTF-8</encoding> <orderFile>ascending</orderFile> <keepFormat>true</keepFormat> <driverProperties>characterEncoding=utf8, connectionCollation=utf8_general_ci, sql_mode=STRICT_TRANS_TABLES</driverProperties> </configuration> <executions> <execution> <id>execution-mysql</id> <phase>prepare-package</phase> <goals> <goal>execute</goal> </goals> <configuration> <url>jdbc:mysql://${db.url}:${db.port}</url <delimiterType>normal</delimiterType> <fileset> <basedir>${project.build.directory}/sql/</basedir> <includes> <include>${file.sql}</include> </includes> </fileset> </configuration> </execution> </executions> </plugin>
source share