简体   繁体   English

无法使用12c jar创建Eclipse数据源到Oracle 12c。 然而11g的作品

[英]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: 当我打开Data Source Explorer窗口并尝试创建新的连接配置文件时,我选择“Oracle”,Oracle Thin Driver,然后将其指向我PC上的以下JAR文件:

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 提供连接参数后,它使用以下格式导出以下格式的连接URL

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. 我似乎能够使用生成的URL连接到11g数据库,但是,不是12c,我不知道这是巧合还是我有不同的问题。

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. 在我的程序中,我使用JPA,它从我的配置文件中以所需的正斜杠格式读取连接URL,并且程序能够连接,如果我更改url使用冒号而连接失败。

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? 如果我无法控制派生连接URL以生成带斜杠而不是冒号的URL,如何在Eclipse的Data Source Explorer视图中创建连接配置文件? The error I am getting is: 我得到的错误是:

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

Update 1 更新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." 我注意到的一件事是,即使我关联了Oracle 12c附带的jdbc7.jar文件,驱动程序仍然显示为“Oracle 11”。

在此输入图像描述

Update 2: 更新2:

Here is a sample of what is in my tnsnames.ora file: 以下是我的tnsnames.ora文件中的示例:

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. 看起来连接字符串构建器只需要一个SID。 what would my SID be or how can I find out? 我的SID是什么,或者我怎么知道? I tried both AFDEDEV and AFDEDEV.MYCO.COM. 我试过了AFDEDEV和AFDEDEV.MYCO.COM。 In the 11g case that did work, I used the equivalent of AFDEDEV. 在11g确实有效的情况下,我使用了相当于AFDEDEV的东西。 Sorry, I don't really understand SIDs vs. SERVICE NAMES that well. 对不起,我真的不太了解SID与服务名称。 Is there a query that I could perform against the db to tell me the SID? 是否有我可以对数据库执行的查询告诉我SID?

This seems to be a restriction of the Eclipse 'Oracle Thin Driver' template. 这似乎是对Eclipse“Oracle Thin Driver”模板的限制。 It is only allowing you to specify a SID for the connection, not a service name; 它只允许您为连接指定SID,而不是服务名称; and either you don't know the SID or it isn't registered with the listener (which your DBA would need to resolve). 并且您要么不知道SID,要么没有向侦听器注册(您的DBA需要解析)。

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. 如果您从“Oracle Database 11g驱动程序”模板而不是“Oracle Thin Driver”模板创建新驱动程序,并将其指向12c ojdbc7.jar文件,那么您将能够选择提供服务名称。 That will then generate a URL like jdbc:oracle:thin:@//servername.sys.MYCO.com:2/afdedev.MYCO.com . 然后,它将生成一个类似jdbc:oracle:thin:@//servername.sys.MYCO.com:2/afdedev.MYCO.com的URL 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, 它仍然是相同的瘦驱动程序,Eclipse似乎更好地理解它,

You can also create a profile from 'Other Driver' template, add ojdbc7.jar in Add Jars section. 您还可以从“其他驱动程序”模板创建配置文件,在“添加Jars”部分中添加ojdbc7.jar。

Now, you can specify the URL string and other parameters yourself and the template will not auto-fill anything for you. 现在,您可以自己指定URL字符串和其他参数,模板不会自动为您填充任何内容。 This way you can provide service name with a preceding '/'. 这样,您可以使用前面的“/”提供服务名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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