我正在尝试使用sql-maven-plugin在Oracle 11数据库上执行PL/SQL脚本.虽然脚本是有效的PL/SQL(据我所知),执行会给我一个PLS-00103错误:
SQL脚本:(drop_all_tables.sql)
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE MY_TABLE';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -942 THEN
RAISE;
END IF;
END;
Run Code Online (Sandbox Code Playgroud)
我的插件配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>oracle</groupId>
<artifactId>jdbc</artifactId>
<version>11.2.0.2.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>create-schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>${jdbc.url}</url>
<username>${jdbc.username}</username>
<password>${jdbc.password}</password>
<autocommit>true</autocommit>
<srcFiles>
<srcFile>src/main/resources/sql/drop_all_tables.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
这是Maven执行的输出:
[ERROR] Failed to execute: BEGIN
EXECUTE IMMEDIATE 'DROP TABLE MY_TABLE';
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] ORA-06550: line 2, column 43:
PLS-00103: Encountered …Run Code Online (Sandbox Code Playgroud) 如何在H2数据库ON UPDATE中执行CREATE TABLE请求.
语境:
我正在使用sql-maven-plugin(1.5)在我的项目中的h2数据库中生成一个表.
但是当我调用脚本sql时,我有一个org.h2.message.DbException.getJdbcSQLException.
我的剧本:
CREATE TABLE IF NOT EXISTS TEST(
DATE timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
);
Run Code Online (Sandbox Code Playgroud) TL; DR版本:我希望能够使用Maven Mojo SQL插件通过mvn命令行随意创建/删除我的数据库模式中的任何给定表(或者为这些表加载数据).怎么样?
我是一名长期的Java开发人员,但在大多数情况下,我一直生活在一个ant基于世界的领域.我喜欢它的力量和显而易见性ant,以及它给我带来的控制力.然而,在我的新工作中,有一种推动使用maven.所以我决定使用我在家工作的项目来学习它.
我在不同的个人项目上设置的一件事是能够ant从命令行完全设置和拆除我的Postgres数据库.我可以单独或一致地对任何表格,序列和集成测试数据进行切片和切块.当然,这意味着我有大约一个ant目标,但它的效果非常好.我喜欢这个; 多年来它一直很好用.
在研究如何在周末在Maven中完成此任务时,我找到了Mojo SQL Maven插件.在查看使用情况页面(我使用该术语时,因为它实际上只是一个没有解释的半示例)和示例页面后,我能够对我的pom.xml文件进行一些更改.我在示例(postgressql)中修复了一些明显的拼写错误,并引用了PostgreSQL JDBC页面以确保我的JDBC连接字符串正确.我将粘贴所有pom.xml(修改为保护有罪)下面:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>JBoss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.0.CR7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-606.jdbc4</version>
</dependency>
</dependencies>
<configuration> …Run Code Online (Sandbox Code Playgroud) maven-surefire-plugin支持通过配置选项使用该java.library.path属性<argLine>.
我需要将java.library.path属性传递给sql-maven-plugin(没有<argLine>配置选项)才能将jTDS驱动程序与windows身份验证一起使用(需要ntlmauth.dll).
在此先感谢您的帮助.
对于我们的 end-2-end 测试,我们需要执行以下逻辑流程:
pre-integration-test)pre-integration-test)pre-integration-test)pre-integration-test)integration-test使用 Protractor在 Tomcat ( ) 中运行 Web 应用程序post-integration-test)post-integration-test)对于运行 SQLsql-maven-plugin使用,但是此流程不适合常规 POM 布局:
pre-integration-test两次,之前和之后的liquibase-maven-pluginpre-integration-test,但是它必须在during之后运行post-integration-test,以便在 Tomcat 关闭后删除 DB 模式。据我从Maven docs …
我正在使用 sql-maven-plugin 在多个数据库上执行一些 MySQL 脚本。我想在同一个 SQL 脚本中部署表、数据、触发器、事件和存储过程。
我的行分隔符有问题,因为对于 INSERT 或 CREATE,我使用;,但是对于我的触发器,我必须使用 更改分隔符DELIMITER //,例如。
我知道插件允许更改分隔符,但它适用于所有脚本,我只想更改唯一脚本的一部分的分隔符。
这是我的 Maven 配置:
<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>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<username>${db.user}</username>
<password>${db.passwd}</password>
<encoding>UTF-8</encoding>
<orderFile>ascending</orderFile>
<keepFormat>true</keepFormat>
<driverProperties>characterEncoding=utf8,
connectionCollation=utf8_general_ci,
sql_mode=STRICT_TRANS_TABLES</driverProperties>
</configuration>
<executions>
<execution>
<id>execution-mysql</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:mysql://${db.url}:${db.port}</url
<delimiterType>normal</delimiterType>
<fileset>
<basedir>${project.build.directory}/sql/</basedir>
<includes>
<include>${file.sql}</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我试图在settings.xml中使用加密密码.我在我的pom.xml中有一个连接到数据库的插件,使用sql-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.4</version>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5.0</version>
</dependency>
</dependencies>
<configuration>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@ip.com:1521:SID</url>
<username>someUser</username>
<password>{JucQpWS78Q0HW+3ZS/FCCGHQpwbJ8ySl2Io/ILJqf88=}</password>
</configuration>
<executions>
<execution>
<id>update-configuration</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<autocommit>false</autocommit>
<srcFiles>
<srcFile>src/main/sql/update_sim_configuration.sql</srcFile>
</srcFiles>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
哪个工作正常如果我将密码作为纯文本放在我的pom.xml中,我想从我的settings.xml读取此密码,密码以这种方式加密:
mvn -ep the_password
Run Code Online (Sandbox Code Playgroud)
我在我的settings.xml中
...
<server>
<id>rms13-db-dev</id>
<username>user</username>
<password>{JucQpWS78Q0HW+3ZS/FCCGHQpwbJ8ySl2Io/ILJqf88=}</password>
</server>
...
Run Code Online (Sandbox Code Playgroud)
我想'读'解码'rms13-db-dev'中的'密码',我该如何实现?或者如果您有替代版本来实现这一目标.