-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Tomcat JNDI datasource question
PostPosted: Mon Sep 29, 2003 9:28 am 
Newbie

Joined: Wed Aug 27, 2003 2:43 am
Posts: 19
Location: Paris
Hello,

I am using Hibernate over some DBCP JNDI Tomcat datasources and there are some things I don't understand:

What is the correllation/difference between the properties listed in Table 2.2 of the documentation:

hibernate.connection.datasource
hibernate.jndi.url
hibernate.jndi.class

and the property at chapter 2.5.7 "JNDI-bound SessionFactory"

hibernate.session_factory_name ?

Should I use them both in order to use a Tomcat context-level configurated JNDI datasource?


Top
 Profile  
 
 Post subject: Re: Tomcat JNDI datasource question
PostPosted: Mon Sep 29, 2003 10:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Quote:
hibernate.connection.datasource
hibernate.jndi.url
hibernate.jndi.class

These define the lookup attributes for the external managed datasource pool.
(Last two attributes are optional)

and
Quote:
and the property at chapter 2.5.7 "JNDI-bound SessionFactory"

hibernate.session_factory_name ?

Should I use them both in order to use a Tomcat context-level configurated JNDI datasource?


include this if you want Hibernate to place the Sessionfactory also into JNDI so it can be looked up similarly as you would if using the datasource directly when using JDBC.


Top
 Profile  
 
 Post subject: Re: Tomcat JNDI datasource question
PostPosted: Mon Sep 29, 2003 11:15 am 
Newbie

Joined: Wed Aug 27, 2003 2:43 am
Posts: 19
Location: Paris
Ok, thank you for your answer. So my understanding is that if I want to use a datasource managed by Tomcat's default DBCP connection pooling, I should only use the
Code:
hibernate.connection.datasource
property.

And that's exactly what I do, in fact... My problems come from the fact that I keep getting a JDBC exception from Hibernate after some server uptime: "Connection already closed'. I don't have the entire backtrace anymore, sorry, and it is not reproduceable, for now. It is true that there are other programs connection to the same database by pure JDBC; some others even by Windows ODBC.

Here is my Tomcat JNDI datasource configuration, in case somebody already met this situation (this is the web-application's <context>):

Code:

    <Resource name="jdbc/production" auth="Container"
        type="javax.sql.DataSource"/>

    <ResourceParams name="jdbc/production">
        <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
        </parameter>
        <parameter>
            <name>maxActive</name>
            <value>10</value>
        </parameter>
        <parameter>
            <name>maxIdle</name>
            <value>5</value>
        </parameter>
        <parameter>
            <name>maxWait</name>
            <value>10000</value>
        </parameter>
        <parameter>
            <name>username</name>
            <value>USER</value>
        </parameter>
        <parameter>
            <name>password</name>
            <value>PASSWORD</value>
        </parameter>
        <parameter>
            <name>driverClassName</name>
            <value>com.sybase.jdbc2.jdbc.SybDriver</value>
        </parameter>
        <parameter>
            <name>url</name>
            <value>jdbc:sybase:Tds:MACHINE:5000/base</value>
        </parameter>
        <parameter>
            <name>removeAbandoned</name>
            <value>true</value>
        </parameter>
        <parameter>
            <name>removeAbandonedTimeout</name>
            <value>1800</value>
            <!-- 30 minutes * 60 secondes -->
        </parameter>
        <parameter>
            <name>logAbandoned</name>
            <value>true</value>
        </parameter>
        <parameter>
            <name>defaultAutoCommit</name>
            <value>false</value>
        </parameter>
        <parameter>
            <name>testOnBorrow</name>
            <value>true</value>
        </parameter>
        <parameter>
            <name>testOnReturn</name>
            <value>true</value>
        </parameter>
        <parameter>
            <name>validationQuery</name>
            <value>select 1</value>
        </parameter>
    </ResourceParams>



Top
 Profile  
 
 Post subject: JNDI tomcat DBCP problem
PostPosted: Fri Oct 03, 2003 6:04 am 
Newbie

Joined: Wed Aug 27, 2003 2:43 am
Posts: 19
Location: Paris
Hello I'am coming back with my Tomcat JNDI dbcp problem.

I get a "Connection already closed exception" on an application which uses both:

* direct access to a context-level JNDI-configured datasource and
* Hibernate db access, through the same JNDI-configured datasource

I use the DBCP nighbuild as of 2 october 2003 in order to avoid some other bugs which were only recently solved (connection hanged). Yes, I read the mails on the Hibernate forum saying not to use dbcp but c3p0 or proxool, but I did not find yet an ObjectFactory implementation for them (for easy integration into my context.xml Tomcat file).

Here is, once again, the way I define my JNDI datasource in the Tomcat <context>. I also have my randomly-appearing exception, pasted to the end of this mail.

Thank you for your ideas!


<Resource name="jdbc/production" auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="jdbc/production">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>
<parameter>
<name>username</name>
<value>USER</value>
</parameter>
<parameter>
<name>password</name>
<value>PASSWORD</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:sybase:Tds:MACHINE:5000/base</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>1800</value>
<!-- 30 minutes * 60 secondes -->
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>defaultAutoCommit</name>
<value>false</value>
</parameter>
<parameter>
<name>testOnBorrow</name>
<value>true</value>
</parameter>
<parameter>
<name>testOnReturn</name>
<value>true</value>
</parameter>
<parameter>
<name>validationQuery</name>
<value>select 1</value>
</parameter>
</ResourceParams>




The exception:


6905644 [Thread-10] ERROR net.sf.hibernate.util.JDBCExceptionReporter - JZ006:
IOException d


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.