title: java.sql.SQLException: Listener refused the connection with the following error: ORA-12505
body: <p>Hi i am beginner and present I have installed Oracle 10g Express Edition Release 2 in my windows 7 64 bit OS and tried to execute Hibernate program but i am getting below exceptions can some one help me please</p>
  
  <pre><code>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.&lt;init&gt;(PhysicalConnection.java:414)
      at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(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)
  </code></pre>
  
  <h2>hibernate.cfg.xml:-</h2>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration SYSTEM 
  "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  
  &lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
   &lt;property name="connection.driver_class"&gt;oracle.jdbc.driver.OracleDriver&lt;/property&gt;
   &lt;property name="connection.url"&gt;jdbc:oracle:thin:@localhost:1521:xe&lt;/property&gt;
   &lt;property name="connection.username"&gt;scott&lt;/property&gt;
   &lt;property name="connection.password"&gt;tiger&lt;/property&gt;
   &lt;property name="connection.pool_size"&gt;10&lt;/property&gt;
   &lt;property name="dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
   &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
   &lt;property name="show_sql"&gt;true&lt;/property&gt;
   &lt;mapping resource = "resources/Dept.hbm.xml"/&gt;
   &lt;mapping resource = "resources/Employee.hbm.xml"/&gt;
   &lt;mapping resource = "resources/Student.hbm.xml"/&gt;
  
  &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>