Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:49:25+00:00 2026-06-17T16:49:25+00:00

I want Maven to execute the sql file, and the database schema it generates

  • 0

I want Maven to execute the sql file, and the database schema it generates will be later used in my program. But it doesn’t work, maybe caused by ‘DELIMITER’. When I execute ‘mvn sql:execute’, it prints that

[ERROR] Failed to execute:  DELIMITER $$

Here is part of my pom.xml

        <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>
            <executions>
                <execution>
                    <id>init-schema</id>
                    <goals>
                        <goal>site</goal>
                    </goals>
                    <phase>deploy</phase>
                </execution>
            </executions>
            <configuration>
                <driver>com.mysql.jdbc.Driver</driver>
                <username>root</username>
                <password>root</password>
                <url>jdbc:mysql://127.0.0.1:3306/?useUnicode=true&amp;characterEncoding=UTF-8</url>
                <autocommit>false</autocommit>
                <srcFiles>
                    <srcFile>src/main/sql/jellyjolly-schema.sql</srcFile>
                </srcFiles>
            </configuration>
        </plugin>

Here is part of my sql file

DELIMITER $$

USE `jellyjolly_schema`$$
DROP TRIGGER IF EXISTS `jellyjolly_schema`.`delete_user` $$
USE `jellyjolly_schema`$$


CREATE TRIGGER delete_user
AFTER DELETE
ON jj_users
FOR EACH ROW
BEGIN
    ## delete the posts that belong to the user
    DELETE FROM jj_blog_posts WHERE author_user_id=OLD.user_id;
END
$$

Is it because the keyword ‘DELIMITER’ is not supported by MySQL Java connector which is invoked by Maven. So how can I solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:49:25+00:00Added an answer on June 17, 2026 at 4:49 pm

    After reading your comments, I believe the best solution is the one accepted here. That is, use only one delimiter (preferably the default, ;) and use the sql-maven-plugin configuration to require the delimiter to occur on it’s own line to actually be a delimiter.

    
        &ltconfiguration&gt
          &ltdelimiterType&gtrow&lt/delimiterType&gt
        &lt/configuration&gt
    
    

    (credit to @Zheka)

    Your trigger would then look like:

    CREATE TRIGGER delete_user
    AFTER DELETE
    ON jj_users
    FOR EACH ROW
    BEGIN
        ## delete the posts that belong to the user
        DELETE FROM jj_blog_posts WHERE author_user_id=OLD.user_id; # this delimiter is ignored
    END
    ; # this delimiter is recognized
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a Maven compilation by my Java code. Thus, I've used
In my maven project I want to assemble an ipkg file (This is like
I want to use the Hibernate3 maven plugin in one of my projects. But,
I am novice to maven (as well as to hibernate) but want to learn
I want to use Maven for PHP with PHPUnit but when I run my
I want to execute a build.xml (Ant buildfile) from using GMaven (Maven Plugin for
I want to package my test package to jar file . How to execute
I am using the sql-maven-plugin to execute some MySQL scripts on several databases. I
I got solution for ant but how can I execute DOS command through maven
I have a Maven pom that uses <packaging>war</packaging> . But actually, I don't want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.