嗨,我是初学者和现在我已经在我的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)
<?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>
答案 0 :(得分:0)
它显示您的实例名称为xe,请确保xe是您已安装实例。
如果没有,请更改实例名称。
不是服务器名称。
答案 1 :(得分:0)
错误消息显示给出的SID未知。请通过连接到任何架构并运行以下任何查询来确保已安装实例的SID为“xe”
select instance from v$thread;
select name from v$database;
或键入sqlplus
命令提示符
show parameter instance_name;