Hello there,
I am now working on a docker project with two docker containers - one for the oracle db and the other with a java application.
The container for oracle db is working ok. I used the already built image for oracle and created my tablespaces and users in it.
Commands I used to pull and use the oracle db container is as given below:
docker pull oracle11g
docker run -d -p 49160:22 -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true oracle11g
Now I have my own Java application that interacts with the oracle db and I run it using the command given below:
docker run -it --name mypgm myrepo/oracletesting
It runs an interactive java program that asks for the Oracle DB details and allows users to interact with the DB.
However I could not figure out how I have to specify details such as
Driver Name, Connection URL, Username, and Password
The values I gave are as given below:
Driver Name: oracle.jdbc.OracleDriver Connection URL: jdbc:oracle:thin:@**localhost:1521**:orcl11g
I think I am getting the Connection URL
wrong and the hence my program is not working.
I tried giving different inputs for Connection URL after inspecting the docker container ip address as well:
Connection URL: jdbc:oracle:thin:@ContainerIPAddress:1521:orcl11g
Am I giving the Connection URL and/or the port number correct? Can someone help me out to correctly connect these two containers and to get the project moving?
Thanks for your kind help…
Two things stand out:
-
You’re mapping the server’s 1521 port to port 49160 on the host but you’re still trying to use 1521 in the connection strnig.
-
You’re trying to use localhost in the connection string when the testing app is running in it’s own container.
There’s a few ways around this, in order of preference (in my opinion):
-
Create a docker network using “docker network create” and then use the --net option on the run commands to hook both the server and the client into the network. If you also use the --name option on the server container then you can then reference it from the client with “my_chosen_name:1521”
-
Use the older --link option on the client run command.
-
Carry on using the host port mapping but change the connection string to “hosts_ip:49161”.
1 Like
Thanks @richardpayne for your kind help… It worked…!
Thanks a lot.
AJ
1 Like
Hi , I am also having similar scenario. I am able to start my db container and the java application container but it wasn’t interacting with oracle db. after running below command how you are giving the DB details like Driver Name, Connection URL, Username, and Password
docker run -it --name mypgm myrepo/oracletesting
Where did you provide those details. in Docker file of java application container? or Docker file for oracle db container?.
After starting the java application container i am getting as follows on console. Where i can provide DB details.
ruleeditor_1 | [AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 14.016 seconds.
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/openapi/
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/metrics/
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/jwt/
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/openapi/ui/
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/ibm/api/
ruleeditor_1 | [AUDIT ] CWWKT0016I: Web application available (default_host): http://rehost:9080/health/
Please help
HI , This is what I was doing. I created both containers using same net work as follows.
docker run --publish 9088:9080 -d –network oracle_net --name recontainer17 reimage17
docker run -it -p 1521:1521 -e DB_PASSWORD=“india123” –network oracle_net --name redbcontainer redbdocker:latest
now I logged into java application container and trying to test the connectivity with dbcontainer using “isql XE DEFMODWAS defmodwas -v”. but it says
“[IM002][unixODBC][Driver Manager]Data source name not found and no default driver specified
[ISQL]ERROR: Could not SQLConnect” where DEFMODWAS is DB name and defmodwas is DB PW
how will I test the connectivity of both contaoners.