Oracle Hibernate Configuration

Fixing Cannot Open Connection Issue

If you receive an error along the lines of:

org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
...
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12518, TNS:listener could not hand off client connection
The Connection descriptor used by the client was:
192.168.4.65:1521:ONTRGS

you probably need to specify the connection release mode for hibernate in your hibernate.cfg.xml file:

<hibernate-configuration>
  <session-factory>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.dialect">org.hibernatespatial.oracle.OracleSpatial10gDialect</property>

    <property name="hibernate.connection.release_mode">auto</property>

    <property name="hibernate.jdbc.use_scrollable_resultset">true</property>

    <mapping class="ca.intelliware...." />
  </session-factory>
</hibernate-configuration>

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply