Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

[Sqoop] Using two versions of the same driver - Oracle ojdbc6.jar

avatar
Explorer

Hello, 

I am on a CDH 5.4.4 cluster, with parcels.

I need to use sqoop, running it from the edgenode.

My problem is that I need to connect to Oracle 12, which works fine, but now I need to connect to Oracle 9, too.

It seems that Oracle12 ojdbc6.jar no more support Oracle9. I need to download Oracle11's ojdbc6.jar

My question is: how can I make them live toghether ?

- I can't place them on the same folder, because they have the same name.

- Maybe I can change the name of one of them, but the classes contained have the same name: how can I tell Sqoop to use one instead of another at runtime ?

 

I'm going nuts.

 

Thank you

 

Omar

 

1 ACCEPTED SOLUTION

avatar
Mentor
You can simply install the O12 jar as the default (under /var/lib/sqoop/) and do the below when you want to use O11 jar over O12 jar instead (don't install the O11 jar into /var/lib/sqoop, but keep it elsewhere):

export HADOOP_CLASSPATH=/path/to/ojdbc6-for-O11.jar
export HADOOP_USER_CLASSPATH_FIRST=true
sqoop …rest of args…

Does this help?

View solution in original post

6 REPLIES 6

avatar
Mentor
You can simply install the O12 jar as the default (under /var/lib/sqoop/) and do the below when you want to use O11 jar over O12 jar instead (don't install the O11 jar into /var/lib/sqoop, but keep it elsewhere):

export HADOOP_CLASSPATH=/path/to/ojdbc6-for-O11.jar
export HADOOP_USER_CLASSPATH_FIRST=true
sqoop …rest of args…

Does this help?

avatar
Explorer
Thank you Harsh, you keep this forum rolling !
I'll try this, a question: will I be missing something overwriting the default hadoop classpath ?

avatar
Mentor
No, the illustrated technique prepends to a default classpath, and does not
replace/overwrite it.

To be extra safe though, if you already are using HADOOP_CLASSPATH for
something else, you may also do it this way:

export HADOOP_CLASSPATH=/path/to/O-9.jar:$HADOOP_CLASSPATH
export HADOOP_USER_CLASSPATH_FIRST=true
sqoop …rest of args…

avatar
Explorer
Yes I guessed it.
So just to be super-safe, according to the last example if it finds a ojdbc6.jar in both paths, it will load the first one and discard the latter, right ?

avatar
Mentor
Yes, that's been the usual JVM behaviour for class-loaders (pick classes
from the earliest classpath entry presenting it), so we are effectively
reordering our classpath to rely on that.

avatar
Explorer
Thanks, will let you know.
Bye