0

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

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

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

如果我使用 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 数据是否存在一般问题?

4

0 回答 0