javasqloracle-databasemavensql-maven-plugin

<outputFile> property not working properly while using sql-maven-plugin


I am using sql-maven-plugin to perform a simple DB testcase.

Firstly , I am inserting 2 rows of data into a table(note: I am truncating the table manually before doing this)

Then I am running a select query to check if those 2 rows are inserted.

To check if those 2 rows are inserted I am using property of sql-maven-plugin to get the query result in a file.

But after running maven, output file is created but it does not contain any data. Size is of 0 KB.

Please suggest where Im going wrong or any other method of getting output of query in a file using maven-sql-plugin.

Thanks in Advance

Added executions tag of my pom.xml below :-

      <execution>
        <id>insert-data</id>
        <phase>process-test-resources</phase>
        <goals>
          <goal>execute</goal>
        </goals>
        <configuration>
          <autocommit>true</autocommit>

          <srcFiles>
            <srcFile>insert-in-usage.sql</srcFile>
          </srcFiles>
        </configuration>
      </execution>

      <execution>
        <id>select-data</id>
        <phase>process-test-resources</phase>
        <goals>
          <goal>execute</goal>
        </goals>

        <configuration>
         <sqlCommand>select distinct decode(count(*),2,'PASS','FAIL') as results from usage where version='3';</sqlCommand>
          <outputFile>result.xls</outputFile>
        </configuration>
      </execution>

    </executions>

Solution

  • For new users coming here after years like me: you have to add the parameter

    <printResultSet>true</printResultSet>
    

    in the configuration. It's been available since version 1.3, according to documentation.