本文介绍了无法使用12c jar创建Eclipse数据源到Oracle 12c。然而11g的作品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我打开Data Source Explorer窗口并尝试创建新的连接配置文件时,我选择Oracle,Oracle Thin Driver,然后将其指向我PC上的以下JAR文件:

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

我似乎可以连接到11g数据库使用生成的url,但不是12c,我不知道这是巧合还是我有不同的问题。

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.

在我的程序中我使用JPA它从我的配置文件中读取连接URL所需的正斜杠格式,如果我更改网址而不是使用冒号,则程序能够连接并且连接失败。

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.

如何创建连接配置文件Eclipse的Data Source Explorer视图,如果我无法控制派生的连接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? The error I am getting is:

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

更新1

我注意到的一件事是,即使我关联了Oracle 12c附带的jdbc7.jar文件,驱动程序仍然显示为Oracle 11。

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."

更新2:

以下是我的tnsnames.ora文件中的内容示例:

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)
    )
  )

它l像连接字符串构建器这样的ooks只需要一个SID。我的SID是什么,或者我怎么知道?我试过了AFDEDEV和AFDEDEV.MYCO.COM。在11g确实有效的情况下,我使用了相当于AFDEDEV的东西。对不起,我真的不太了解SID与服务名称。是否有我可以对数据库执行的查询告诉我SID?

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?

推荐答案

这似乎是对数据库的限制EclipseOracle Thin Driver模板。它只允许您为连接指定SID,而不是服务名称;并且您不知道SID或者它没有在监听器中注册(您的DBA需要解析)。

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).

如果您从以下位置创建新驱动程序Oracle数据库11g驱动程序模板,而不是Oracle瘦驱动程序模板,并将其指向您的12c ojdbc7.jar文件,然后您将能够选择提供服务名称。然后,这将生成一个URL,如 jdbc:oracle:thin:@ // servername.sys.MYCO.com:2/afdedev.MYCO.com

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.

它仍然是相同的瘦驱动程序,Eclipse似乎更好地理解它,

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

这篇关于无法使用12c jar创建Eclipse数据源到Oracle 12c。然而11g的作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:51