简体   繁体   中英

Unable to create Eclipse Data Source to Oracle 12c using 12c jar. However 11g works

When I open up the Data Source Explorer window and try to create a new Connection Profile, I select "Oracle", the Oracle Thin Driver, and then I point it to the following JAR file on my PC:

C:\oracle_12101_64bit\product\12101_64bit\CLIENT_1\jdbc\lib\ojdbc7.jar

After supplying the connection parameters, it derives a connection url in the following format using the

jdbc:oracle:thin:@host:PORT:SID

However, what I want it to derive is this (note the colon instead of a forward slash)

jdbc:oracle:thin:@host:PORT/SID

I seem to be able to connect to 11g databases using the generated url, however, not a 12c, I don't know if this is coincidental or if I have a different issue.

In my program I use JPA and it reads a connection url from my config file in the desired forward slash format and the program is able to connect and the connection fails if I change the url to use a colon instead.

How do I create a Connection Profile in the Eclipse's Data Source Explorer view if I cannot control the derived connection url to generate a url with a slash instead of a colon? The error I am getting is:

ORA-12505, TNS:listener does not currently know of SID given in connect descriptor

Update 1

One thing that I noticed is that even if I associate the jdbc7.jar file that comes with Oracle 12c, the driver still is displayed as though it is "Oracle 11."

在此输入图像描述

Update 2:

Here is a sample of what is in my tnsnames.ora file:

AFDEDEV.MYCO.COM =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = servername.sys.MYCO.com)(PORT = 2))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = afdedev.MYCO.com)
    )
  )

在此输入图像描述

It looks like the connection string builder expects only a SID. what would my SID be or how can I find out? I tried both AFDEDEV and AFDEDEV.MYCO.COM. In the 11g case that did work, I used the equivalent of AFDEDEV. Sorry, I don't really understand SIDs vs. SERVICE NAMES that well. Is there a query that I could perform against the db to tell me the SID?

This seems to be a restriction of the Eclipse 'Oracle Thin Driver' template. It is only allowing you to specify a SID for the connection, not a service name; and either you don't know the SID or it isn't registered with the listener (which your DBA would need to resolve).

If you create a new driver from the 'Oracle Database 11g Driver' template, rather than the 'Oracle Thin Driver' template, and point it to your 12c ojdbc7.jar file, then you will be able to choose to supply a service name instead. That will then generate a URL like jdbc:oracle:thin:@//servername.sys.MYCO.com:2/afdedev.MYCO.com .

It's still the same thin driver, Eclipse just seems to understand it better,

You can also create a profile from 'Other Driver' template, add ojdbc7.jar in Add Jars section.

Now, you can specify the URL string and other parameters yourself and the template will not auto-fill anything for you. This way you can provide service name with a preceding '/'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM