Reputation: 758
I am currently running a WAR file within an Apache Tomcat Docker container. The war file is a Spring Boot Application. The application.properties contain a connection using oracle jdbc6 connection to the database. The jar file is included in the Maven build. I continue to receive a 500. I can run the same WAR file on my local machine and all connections work fine. That is why I am assuming its because of open ports on the docker container.
sudo docker run -d -p 8080:8080 -p 1521:1521 --restart unless-stopped fd13ad9f3e16
I opened the ports up for 1521 but still cannot access the database.
Is there anything else I need to run on my docker container in order to access the Oracle JDBC connection outside?
Upvotes: 1
Views: 1904
Reputation: 758
So here are the steps I took in AWS to make sure that this is working on my Tomcat Docker instances for JDBC connection. You do not need to run -p 1521:1521 since the docker container is only a Tomcat instance and not hosting Oracle. Make sure you set the application.properties file (below is an example)
spring.datasource.url=jdbc:oracle:thin:@//< DNS name for RDS>:1521/<SID>
spring.datasource.username=<oracle db username>
spring.datasource.password=< oracle db password for username>
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
#hibernate config
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
#spring.data.rest.base-path=/api
spring.data.rest.default-page-size: 20
Next, make sure that your RDS security group is set up to allow the specific IP address of your EC2 instances. I would not recommend opening up to all.
Next, make sure to open up the security group for the EC2 instance for 1521.
That should be it. The problem I was having was with the RDS security group not be specifically configured for my EC2 instance.
You can also install SQLplus using RPM packages from Oracle to test your connection as well. Example command would be:
sqlplus '<username>/<password>@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=<aws DNS name>)(Port=1521))(CONNECT_DATA=(SID=<name of SID>)))'
Upvotes: 1