Embedded or managed Oracle instance for integratio

2019-07-19 18:31发布

问题:

For MySQL, the MXJ connector makes it very easy to launch a managed MySQL instance.

I know that Oracle provides Oracle XE for quick setup, but I've only found an RPM distribution that needs to be installed. Is there a neatly packaged jar that I can just drop in the classpath and start up by calling a specific JDBC url, a la HSQLDB or MXJ?

I'm interested in having developers use this locally for running tests, as well as on our continuous integration server.

回答1:

The short answer is No. Oracle is a big meaty chunk of database. Amongst other things, it generally expects itself to be run by its own special user rather than the client user.

For simplicity, your best bet is a separate DB server with each of your developers having their own username/password (and hence their own independent schema) in the database.



回答2:

Although Oracle does not provide an embedded database, spinning up a local Docker container running Oracle XE might be an ideal way to accommodate Oracle-specific local integration tests. Since Docker containers are ephemeral in nature by design, the database could also be completely torn down as desired providing clean sandboxing.

The alexeiled/docker-oracle-xe-11g image on DockerHub I found has particularly clear setup and documentation instructions: https://hub.docker.com/r/alexeiled/docker-oracle-xe-11g/

After spinning up the Docker container, be sure to:

  • First connect to the APEX web console, login, as per the instructions
  • Then open Oracle SQL Developer and select Reset Password... first. Otherwise the following error may be thrown java.lang.ArithmeticException when attempting to get connection in Oracle 11.2.0.2.0 (64 bit)

As the documentation describes, the docker run command can also be designed to automatically run SQL scripts on the container's startup, which could also be very valuable in the CI/integration testing workflow.

Hope this helps!