1 Reply Latest reply on Apr 23, 2015 10:16 AM by Adam Zimowski

    Arquillian, GlassFish 4.1, and MySQL DELIMITER keyword

    Marc Poissant Newbie

      Hi,

       

      I'm having an issue with my Arquillian tests.

       

      In my deploy() method, I've got:

       

      final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war")

                      .setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))

                      .addPackage(AlbumJpaController.class.getPackage())

                      .addPackage(RollbackFailureException.class.getPackage())

                      .addPackage(Album.class.getPackage())

                      .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")

                      .addAsWebInfResource(new File("src/main/setup/glassfish-resources.xml"), "glassfish-resources.xml")

                      .addAsResource(new File("src/main/resources/META-INF/persistence.xml"), "META-INF/persistence.xml")

                      .addAsResource("create_mydb.sql")

                      .addAsLibraries(dependencies);

       

      Note the "create_mydb.sql" added as a resource.

       

      The issue I'm encountering is when the line in the MySQL script

       

      DELIMITER |

      CREATE TRIGGER my_trg ...

       

      is run, I get an error in my NetBeans 8.0.2 console:

       

      com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER |CREATE TRIGGER my_trg' at line 1

       

      The interesting thing is that when I run the script on my local MySQL database server, it runs without a hitch. I'm trying to isolate the problem, so I'm trying my hand at starting a Discussion here on the forums. So, the error seems to happen when the parser reads the line where I want to start defining my multi-statement trigger. I did some research before posting here, and I have a hunch that the parser (I'm not actually sure what the parser is called) does not know what the DELIMITER keyword is, so it flags it as an error. I've read that that keyword may be only known to the mysql program.

       

      If I run the test having removed the trigger in my script, it's able to start testing, though my database depends upon this trigger in order to function properly.

       

      How does one get around to defining a multi-statement MySQL trigger when loading a script like this?

       

      Need any more info? Let me know! I'm very interested in learning how to overcome this issue, if it's possible at all.