1

Tried different ways

sql

  CREATE TABLE oracle_table
  USING org.apache.spark.sql.jdbc
  OPTIONS (
    dbtable 'persons',
    driver 'oracle.jdbc.driver.OracleDriver',
    user '<user>',
    password '<pass>',
    url 'jdbc:oracle:thin://@<host>:1521/orcl')

above code returned OK

select * from oracle_table

throwed java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

python

jdbcUrl = "jdbc:oracle:thin:@<host>:1521/orcl"
properties = {
    "user": "<user>",
    "password": "<password>",
    "driver": "oracle.jdbc.driver.OracleDriver" 
}

pushdown_query = "( SELECT * FROM persons ) emp_alias"
df = spark.read.jdbc(url=jdbcUrl, table=pushdown_query, properties=properties)
df.printSchema()

returned

 |-- PERSON_ID: decimal(38,10) (nullable = true)
 |-- FIRST_NAME: string (nullable = true)
 |-- LAST_NAME: string (nullable = true)

But for below code

df.show()

throwed java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection

help me!

7
  • Does the CREATE TABLE run straight away? It's probably "lazy loading", meaning that it doesn't run until you actually select from it. So most likely the issue is actually in your create table, and your databricks actually can't connect to <host>:1521. Are you certain your databricks install has network connectivity to the Oracle server? Commented Jul 21, 2020 at 12:50
  • Initally i have faced connectivity error,i have updated the azure inbound and outbound rules ,then it is able to load metadata from table DESCRIBE persons is also giving all columns and datatypes, if there is connectivity issue is shoudn't load the metadata also right!, thats what confusing me Commented Jul 21, 2020 at 13:41
  • 1
    @ChandraPrakash You may checkout similar issue discussed here: stackoverflow.com/questions/52542816/… Commented Jul 22, 2020 at 4:45
  • The %sh telnet trick is pretty handy I'll have to remember that one Commented Jul 22, 2020 at 11:58
  • 1
    i figured out the issue firewall is enabled for only master node of databricks and workers are in private ip .Thats why im able to get metadata but not data Commented Jul 29, 2020 at 15:40

1 Answer 1

1

Sharing the answer as per the comment by the original poster:

I figured out the issue firewall is enabled for only master node of databricks and workers are in private ip. That's why I'm able to get metadata but not data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.