04-13-2023 11:57 AM
Hi Everyone,
I was trying to connect to Oracle Instance from Databricks cluster and it is giving below error:
java.sql.SQLTimeoutException: ORA-12170: Cannot connect. TCP connect timeout of 30000ms for host xx.x.x.*** port 1521. (CONNECTION_ID=CgM7V7UBQDSzltL/SWk9LA==)
I have tried checking the port 1521 is listening mode or not using below:
netstat -aon
and State is Listening.
Also I have ojdbc8.jar in the libraries of the running cluster.
Below is the code template I am using:
jdbcHostname = "Your Host Name"
jdbcPort = 1521
jdbcDatabase = "DB Service Name"
jdbcUsername = "hr"
jdbcPassword = "hr"
jdbcUrl = "jdbc:oracle:thin:@//" + jdbcHostname + ":" + str(jdbcPort) + "/" + jdbcDatabase
# Define connection properties
connectionProperties = {
"user": jdbcUsername,
"password": jdbcPassword,
"driver": "oracle.jdbc.driver.OracleDriver"
}
# Load a table from the Oracle database
df = spark.read.jdbc(url=jdbcUrl, table="employees", properties=connectionProperties)
Please help me with your expertise to solve this.
Thanks and Regards,
Satya
04-14-2023 12:06 AM
The problem is that the Oracle service is running on a IP address, and the host is configured with another IP address.
To see the IP address of the Oracle service, issue an
lsnrctl status command and check the address reported
Try a static IP
04-14-2023 06:35 AM
Thanks Avinash for the reply.
I have checked the IP by using lsnrctl status and it is matching with the given IP and Port number and still getting the same issue.
04-14-2023 07:58 AM
are you able to ping your on prem IP from Databricks using telnet command from notebook if no there is an outbound inbound rule need to be added to you firewall
04-14-2023 08:21 AM
No @Avinash Kumar . I tried with below:
%sh telnet xx.x.x.*** 1521
and getting "telnet: Unable to connect to remote host: Connection timed out"
Please help me in telling where to add for outbound inbound rule to my firewall.
04-16-2023 05:31 AM
Hi you need to get in touch with the networking team and ask them to add an inbound rule to external databricks ip address allowing access to the said IP and port. the rules would be specific to you organization policy.
04-14-2023 12:08 AM
with on-prem connections you have to make sure databricks can reach your oracle environment networkwise, so you might have to change firewall settings or use private endpoints, vnet injection etc.
04-14-2023 06:36 AM
Thanks Werners for your reply.
Could you please let me know where to check for changing the firewall settings ..
04-16-2023 12:29 AM
@Satya89:
The error message you received indicates that the TCP connection to the Oracle database timed out. This could be caused by a number of factors such as network issues, firewall restrictions, or the database being overloaded.
Here are a few steps you can try to troubleshoot and resolve the issue:
I hope these suggestions help you to resolve the issue and connect to the Oracle database from Databricks.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group