由以下原因引起:org.hibernate.HibernateException:当未设置“ hibernate.dialect”时(在Oracle DB上),对DialectResolutionInfo的访问不能为空

时间:2019-02-03 19:20:11

标签: oracle hibernate oracle12c

我已经阅读了有关此问题的其他文章,但是我的不是Hibernate问题,而是连接问题。

我在新计算机上安装了 Oracle数据库12c ,但是无法将Web应用程序连接到它。我收到此错误:

Caused by: org.hibernate.HibernateException: Access to 
DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

我敢肯定,这个问题与连接有关。如果我尝试连接到MySQL数据库,该应用程序将完美运行。

这是我的 tnsnamesora 文件

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

这些是我的连接数据:

spring.datasource.url=jdbc:oracle:thin:@localhost:1521/orcl
spring.datasource.username=DB_EXAMPLE
spring.datasource.password=Frema16242 //this is correct
spring.datasource.database-driver=oracle.jdbc.driver.OracleDriver
hibernate.c3p0.preferred_test_query=SELECT 1 FROM DUAL

这些是在我的PC上运行的Oracle服务。

enter image description here

我当然可以使用Toad连接到我的架构。

您能发现我的错误吗?

1 个答案:

答案 0 :(得分:0)

我认为我也遇到过像您一样的问题。我试图使用数据源设置连接。我将sessionFactory与构造函数数据源参数一起使用。当我创建属性对象并将hibernate.dialect属性添加到它时,我解决了它。接下来,我在sessionFactory对象上设置此属性。