Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Connecting Oracle using Dataframe API

Connecting Oracle using Dataframe API

Hi,

 

With the format of url=“jdbc:oracle:thin:@dburl:port:sid” for oracle, and url = “jdbc:mysql://dburl:port/sid” for MySQL, they worked properly under scala. However under java its not working with below way.

 

DB_CONNECTION_URL = DB_URL+”:”+DB_PORT+”:”+DB_NAME+”,”+DB_USERNAME + “,” + DB_PWD;
DB_CONNECTION_URL = DB_URL+”:”+DB_PORT+”/”+DB_NAME+”?user=”+DB_USERNAME + “&password=” + DB_PWD;

 

Please find the samle code.

 

Map<String, String> options = new HashMap<>();
            options.put("driver", ORACLE_DRIVER);
            options.put("url", ORACLE_CONNECTION_URL);
            options.put("dbtable",
                        "(select * from emp) as data");
            options.put("partitionColumn", "emp_no");
            options.put("lowerBound", "396306");
            options.put("upperBound", "496306");

 

  DataFrame jdbcDF = sqlContext.load("jdbc", options);
                   

 

I'm getting TNS Listner error for the first way

ORA-12514, TNS:listener does not currently know of service requested in connect descriptor

For second way

Exception in thread "main" java.sql.SQLRecoverableException: IO Error: NL Exception was generated.

 

Please help me out.

 

Regards,

Venkat