title: jdbc connection refused while configuring in hibernate
body: <p>I'm using oracle 12c with jar ojdbc7 to configure DB in hibernate.  but i'm getting following error : </p>
  
  <p>org.hibernate.exception.JDBCConnectionException: Error calling Driver#connect
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator$1$1.convert(BasicConnectionCreator.java:122)
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.convertSqlException(BasicConnectionCreator.java:140)
      at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:58)
      at org.hibernate.engine.jdbc.connections.internal.BasicConnectionCreator.createConnection(BasicConnectionCreator.java:75)
      at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
      at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
      at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
      at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
      at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
      at com.vikas.hibernate.HibernateTest.main(HibernateTest.java:21)
  Caused by: 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</p>
  
  <pre><code>at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
  at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:715)
  at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:385)
  at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
  at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
  at org.hibernate.engine.jdbc.connections.internal.DriverConnectionCreator.makeConnection(DriverConnectionCreator.java:55)
  ... 14 more
  </code></pre>
  
  <p>Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
  ORA-12505, TNS:listener does not currently know of SID given in connect descriptor</p>
  
  <pre><code>at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:272)
  at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263)
  at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
  at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
  ... 19 more
  </code></pre>
  
  <p>my hibernate.cfg.xml is as follows: 
          oracle.jdbc.driver.OracleDriver
          jdbc:oracle:thin:localhost:1522/DevDb
          SYSTEM
          oracle123</p>
  
  <pre><code>    &lt;!-- JDBC connection pool (use the built-in) --&gt;
      &lt;property name="connection.pool_size"&gt;1&lt;/property&gt;
  
      &lt;!-- SQL dialect --&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
  
      &lt;!-- Disable the second-level cache  --&gt;
      &lt;property name="cache.provider_class"&gt;org.hibernate.cache.internal.NoCacheProvider&lt;/property&gt;
  
      &lt;!-- Echo all executed SQL to stdout --&gt;
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
  
      &lt;!-- Drop and re-create the database schema on startup --&gt;
      &lt;property name="hbm2ddl.auto"&gt;create&lt;/property&gt;
  </code></pre>
  
  <p>can somebody help me out to resolve this issue.</p>
  
  <hr>
  
  <p>It says</p>
  
  <p>ORA-12505, TNS:listener does not currently know of SID given in connect descriptor</p>
  
  <p>my SID given is correct.</p>