Maven SQL插件无法正确处理BLOB数据

时间:2015-09-03 16:29:15

标签: mysql maven jdbc sql-maven-plugin

我是pom文件的新手,是stackoverflow的新手。

作为集成测试过程的一部分,我在每次运行时删除并重新创建mysql数据库,以确保干净的已知参考数据作为起点。这是通过pom文件完成的,这些文件使用sql-maven-plugin和对mysql-connector-java的依赖。除了最初存储为' blob'或者' longblob'格式。在这些情况下,数据被插入到正确的表/列中,但它是损坏的数据。

插件是通过sql文件处理的,这些文件是从一组主数据库的mysqldump创建的。

如果我使用zcat或mysql将sql文件传输到数据库中,那么一切正常并且数据是正确创建的,所以我认为mysqldump创建的sql语句没有错自己。

为"编码"尝试了各种不同的设置。但这些要么完全失败,要么没有区别。

我很确定我一定会错过一些简单但我不知道的东西!

从我的pom文件中提取:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>sql-maven-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.36</version>
        </dependency>
    </dependencies>
    <configuration>
        <driver>${integration.jdbc.driver}</driver>
        <username>${integration.jdbc.super.username}</username>
        <password>${integration.jdbc.super.password}</password>
        <enableBlockMode>false</enableBlockMode>
    </configuration>
    <executions>
        <execution>
            <id>Clean old databases and create fresh ones</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <autocommit>true</autocommit>
                <forceMojoExecution>true</forceMojoExecution>
                <url>${integration.jdbc.url}</url>
                <sqlCommand>
                    drop database if exists ${integration.app.reposdb.name};
                    create database ${integration.app.reposdb.name};
                </sqlCommand>
            </configuration>
        </execution>
        <execution>
            <id>Apply grants to databases to allow non-privileged access</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <autocommit>true</autocommit>
                <forceMojoExecution>true</forceMojoExecution>
                <url>${integration.jdbc.url}</url>
                <sqlCommand>
                    grant all on ${integration.app.reposdb.name}.* to '${integration.jdbc.username}'@'%' identified by '${integration.jdbc.password}';
                    grant select,usage on ${integration.app.reposdb.name}.* to '${integration.jdbc.ro_username}'@'%' identified by '${integration.jdbc.ro_password}';
                </sqlCommand>
            </configuration>
        </execution>

        <execution>
            <id>Create application file repository db</id>
            <phase>pre-integration-test</phase>
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <autocommit>true</autocommit>
                <forceMojoExecution>true</forceMojoExecution>
                <url>${integration.jdbc.app_repos_url}</url>
                <orderFile>ascending</orderFile>
                <encoding>UTF-8</encoding>
                <fileset>
                    <basedir>${integration.release.data.snapshots}/${data.version}</basedir>
                    <includes>
                        <include>ifv2_repos.sql</include>
                    </includes>
                </fileset>
            </configuration>
        </execution>
...

我应该设置哪些明显的属性但是还没有?通过jdbc处理blob数据是否存在一般问题?

0 个答案:

没有答案