users@glassfish.java.net

Oracle-Hibernate: Auto-Reconnect

From: <glassfish_at_javadesktop.org>
Date: Mon, 04 Feb 2008 01:22:06 PST

Hi folk,

Could anyone help me with how to obtain the same as "jdbc:mysql:/localhost/mydb?[b]autoReconnect=true[/b]" with oracle jdbc driver? Assuming actually, even with MySql, using the autoReconnect parameter is not recommended ([url]http://www.theserverside.com/news/thread.tss?thread_id=24137#111947[/url]).

I don't use Hibernate connection pool but [b]DBCP [/b](with [b]tomcat[/b]) and this not help:
"[i]<property name="connection.autoReconnect">true</property>[/i]": after 8 hours of inactivity I get "connection error" exception.

Can [b]c3p0 [/b] help?
[i]<property name="c3p0.idle_test_period">100</property>[/i]
Is c3p0 really "enterprise ready"?

Here my [i]hibernate.cfg.xml[/i] file:


[code]
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
        <session-factory name="TestSessionFactory">
                <!-- Database connection settings -->
                <!--
                        <property name="hibernate.connection.driver_class">
                        oracle.jdbc.driver.OracleDriver
                        </property>
                        <property name="hibernate.connection.password">tiger</property>
                        <property name="hibernate.connection.url">
                        jdbc:oracle:thin:@10.0.0.14:1521:orcl
                        </property>
                        <property name="hibernate.connection.username">scott</property>
                -->

                <property name="connection.datasource">
                        java:/comp/env/jdbc/SITIP
                </property>

                <!-- JDBC Connection pool -->
                <!-- <property name="connection.pool_size">1</property> -->

                <!-- SQL Dialect -->
                <property name="hibernate.dialect">
                        org.hibernate.dialect.Oracle10gDialect
                </property>

                <!-- Echo alla executed sql to stdout -->
                <property name="show_sql">true</property>
                <property name="format_sql">true</property>
                <property name="use_sql_comments">true</property>

                <!-- Enable Hibernate's automatic session context management -->
                <!-- Use thread-bound persistence context propagation, scoped to the transaction -->

                <property name="current_session_context_class">thread</property>

                <!-- ATTENZIONE: mettendo "create" le tabelle vengono CANCELLATE!!! -->
                <!-- Drop and re-create the database schema on startup -->
                <property name="hbm2ddl.auto">update</property>

                <!-- Seguono gli XML associati alle entità del progetto -->
                <mapping resource= ....
....

        </session-factory>
</hibernate-configuration>
[/code]
[Message sent by forum member 'xerix32' (xerix32)]

http://forums.java.net/jive/thread.jspa?messageID=257228