Quick example of using springboot to write a quick REST API to access some stuff in an Oracle database.
- Java 8
- Maven (because reasons)
- Vagrant: https://www.vagrantup.com/
- Clone this repo (duh)
- Oracle xe installer for linux (I don't care if you're running linux or not, this guy is going in a VM): http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
- Move that guy to
spring-boot-oracle-example/oracle-installer
vagrant up
(in the spring-boot-oracle-example dir)- Congrats, oracle xe is installed(ish) on this VM
vagrant ssh
sudo -i
(act as root)- You'll note from the step above after running
vagrant up
you'll see a message, something like==> default: You must run '/etc/init.d/oracle-xe configure' as the root user to configure the database.
So yeah.. do that. - Use the default ports. And take not of the password you provide.
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
- Set env variables using the script provided from Oracle. This is needed to connect using their sql client.sqlplus /nolog
connect sys as sysdba
- Enter the password you created during config
start /vagrant/create_sql_user_and_tables.sql
- Download the JDBC driver: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
- Here's where things get interesting. Apparently
gradle
can't load this jar from aflatFile
repository. So the workaround is to create a local maven repository and load this 1 jar into it. cd
to the directory where the ojdbc jar is locatedmvn install:install-file -Dfile=ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.4 -Dpackaging=jar
- In the above command make sure to adjust the file, artifactId, and version to match the driver you downloaded.
- If a different version from the one above was used adjust
build.gradle
./gradlew bootRun
- http://localhost:8080/users