gpt4 book ai didi

java.sql.SQLException : Listener refused the connection with the following error: ORA-12505

转载 作者:太空宇宙 更新时间:2023-11-04 11:40:37 24 4
gpt4 key购买 nike

您好,我是初学者,目前我已在 Windows 7 64 位操作系统中安装了 Oracle 10g Express Edition Release 2 并尝试执行 Hibernate 程序,但我遇到以下异常,有人可以帮助我吗

WARNING: Could not obtain connection metadata
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:xe

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:187)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
at test.Test.main(Test.java:11)

hibernate.cfg.xml:-

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<property name="connection.pool_size">10</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hbm2ddl.auto">create</property>
<property name="show_sql">true</property>
<mapping resource = "resources/Dept.hbm.xml"/>
<mapping resource = "resources/Employee.hbm.xml"/>
<mapping resource = "resources/Student.hbm.xml"/>

</session-factory>
</hibernate-configuration>

最佳答案

显示您的实例名称为xe,请确保xe是您已安装的实例。

如果没有,请更改实例名称。

不是服务器名称。

关于java.sql.SQLException : Listener refused the connection with the following error: ORA-12505,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42828262/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com