Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Timeout after 8 hours
[Teneo] Timeout after 8 hours [message #103244] |
Tue, 20 November 2007 16:44 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
Martin,
This isn't really a Teneo question, but I thought maybe you have
stumbled upon this at some point.
It seems that hibernate (with an MySQL server) closes its connection
after 8 hours of inactivity. Have you ever noticed this? Do you have
any suggestions? Is there a way (given my HbDataStore) to determine if
the connection is still open?
Cheers,
Ian
|
|
| |
Re: [Teneo] Timeout after 8 hours [message #103294 is a reply to message #103266] |
Tue, 20 November 2007 18:24 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
Is Teneo using C3P0 by default, or do I have to configure it to do so?
I'm simply configuring my connection as in [1]. I assume that hbds opens
the connection, so I never really deal with them after that. (I simply
create my sessions and transactions as needed).
Do you have any code snippets for setting up C3P0 with Teneo and how to
get at the properties?
cheers,
ian
[1]http://www.elver.org/hibernate/quick_tutorial.html
Martin Taal wrote:
> Ian,
> Afaik there can be several reasons why a connection is closed (jdbc
> driver, database). I think mysql has a specific setting for this (close
> connection after so many idle seconds).
> I use connection pooling by c3p0 and it can automatically (periodically)
> test a connection and removes it from the pool if it is not valid anymore.
> See here:
> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>
>
> gr. Martin
>
> Ian Bull wrote:
>> Martin,
>>
>> This isn't really a Teneo question, but I thought maybe you have
>> stumbled upon this at some point.
>>
>> It seems that hibernate (with an MySQL server) closes its connection
>> after 8 hours of inactivity. Have you ever noticed this? Do you have
>> any suggestions? Is there a way (given my HbDataStore) to determine
>> if the connection is still open?
>>
>> Cheers,
>> Ian
>
>
|
|
|
Re: [Teneo] Timeout after 8 hours [message #103306 is a reply to message #103294] |
Tue, 20 November 2007 18:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
You have to set specific hibernate properties to enable c3p0 (so it is not used by default). See
here (and the hibernate manual):
http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
when you set these properties then hibernate should automatically use c3p0 (provided also that the
c3p0 jar is in the classpath).
You can pass these properties to the datastore just as the other jdbc properties.
Or you can define a datasource to use c3p0. Here is the content of a context.xml file (used in a web
app) as an example. In this case hibernate needs to use a datasource instead of a direct jdbc
connection driver. See the hibernate manual for more information.
<Context path="" privileged="true" antiResourceLocking="false"
antiJARLocking="false">
<Resource name="jdbc/SupplierControl" auth="Container"
maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
maxStatementsPerConnection="50"
maxIdleTime="86400"
numHelperThreads="10"
idleConnectionTestPeriod="3600"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
user="sa"
password=""
driverClass="net.sourceforge.jtds.jdbc.Driver"
jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
</Context>
gr. Martin
Ian Bull wrote:
> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>
> I'm simply configuring my connection as in [1]. I assume that hbds opens
> the connection, so I never really deal with them after that. (I simply
> create my sessions and transactions as needed).
>
> Do you have any code snippets for setting up C3P0 with Teneo and how to
> get at the properties?
>
> cheers,
> ian
>
>
> [1]http://www.elver.org/hibernate/quick_tutorial.html
> Martin Taal wrote:
>> Ian,
>> Afaik there can be several reasons why a connection is closed (jdbc
>> driver, database). I think mysql has a specific setting for this
>> (close connection after so many idle seconds).
>> I use connection pooling by c3p0 and it can automatically
>> (periodically) test a connection and removes it from the pool if it is
>> not valid anymore.
>> See here:
>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> Martin,
>>>
>>> This isn't really a Teneo question, but I thought maybe you have
>>> stumbled upon this at some point.
>>>
>>> It seems that hibernate (with an MySQL server) closes its connection
>>> after 8 hours of inactivity. Have you ever noticed this? Do you have
>>> any suggestions? Is there a way (given my HbDataStore) to determine
>>> if the connection is still open?
>>>
>>> Cheers,
>>> Ian
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Timeout after 8 hours [message #103360 is a reply to message #103306] |
Wed, 21 November 2007 06:02 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
I am doing all my configuration through the properties on the
HbDataStore. I now have the following:
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "root");
props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
databaseName );
props.setProperty(Environment.PASS, password);
props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
props.setProperty(Environment.C3P0_TIMEOUT, "25200");
props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
props.setProperty(Environment.C3P0_MIN_SIZE, "3");
props.setProperty(Environment.C3P0_MAX_SIZE, "100");
Now when I try to perform any database operations I get:
CannotAcquireResourceException: A ResourcePool could not acquire a
resource from its primary factory or source.
Also, hdbs.initialize takes a long time to complete (before it was < 1
second, now it is a minute or two).
Thanks for all the help Martin,
Ian
Martin Taal wrote:
> You have to set specific hibernate properties to enable c3p0 (so it is
> not used by default). See here (and the hibernate manual):
> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
> when you set these properties then hibernate should automatically use
> c3p0 (provided also that the c3p0 jar is in the classpath).
> You can pass these properties to the datastore just as the other jdbc
> properties.
>
> Or you can define a datasource to use c3p0. Here is the content of a
> context.xml file (used in a web app) as an example. In this case
> hibernate needs to use a datasource instead of a direct jdbc connection
> driver. See the hibernate manual for more information.
> <Context path="" privileged="true" antiResourceLocking="false"
> antiJARLocking="false">
> <Resource name="jdbc/SupplierControl" auth="Container"
> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
> maxStatementsPerConnection="50"
> maxIdleTime="86400"
> numHelperThreads="10"
> idleConnectionTestPeriod="3600"
> factory="org.apache.naming.factory.BeanFactory"
> type="com.mchange.v2.c3p0.ComboPooledDataSource"
> user="sa"
> password=""
> driverClass="net.sourceforge.jtds.jdbc.Driver"
> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
> </Context>
>
> gr. Martin
>
> Ian Bull wrote:
>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>
>> I'm simply configuring my connection as in [1]. I assume that hbds
>> opens the connection, so I never really deal with them after that. (I
>> simply create my sessions and transactions as needed).
>>
>> Do you have any code snippets for setting up C3P0 with Teneo and how
>> to get at the properties?
>>
>> cheers,
>> ian
>>
>>
>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>> Martin Taal wrote:
>>> Ian,
>>> Afaik there can be several reasons why a connection is closed (jdbc
>>> driver, database). I think mysql has a specific setting for this
>>> (close connection after so many idle seconds).
>>> I use connection pooling by c3p0 and it can automatically
>>> (periodically) test a connection and removes it from the pool if it
>>> is not valid anymore.
>>> See here:
>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> Martin,
>>>>
>>>> This isn't really a Teneo question, but I thought maybe you have
>>>> stumbled upon this at some point.
>>>>
>>>> It seems that hibernate (with an MySQL server) closes its connection
>>>> after 8 hours of inactivity. Have you ever noticed this? Do you
>>>> have any suggestions? Is there a way (given my HbDataStore) to
>>>> determine if the connection is still open?
>>>>
>>>> Cheers,
>>>> Ian
>>>
>>>
>
>
|
|
|
Re: [Teneo] Timeout after 8 hours [message #103371 is a reply to message #103360] |
Wed, 21 November 2007 06:15 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
A quick guess is that it takes so long because you also set the datasource property so hibernate
will look for a datasource with the name you set (the classname), which it won't find.
Also, I don't think the connection_provider is required.
So can you try without setting the CONNECTION_PROVIDER and DATASOURCE properties?
gr. Martin
Ian Bull wrote:
> I am doing all my configuration through the properties on the
> HbDataStore. I now have the following:
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
> databaseName );
> props.setProperty(Environment.PASS, password);
> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>
>
> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>
> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>
> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>
> Now when I try to perform any database operations I get:
>
> CannotAcquireResourceException: A ResourcePool could not acquire a
> resource from its primary factory or source.
>
> Also, hdbs.initialize takes a long time to complete (before it was < 1
> second, now it is a minute or two).
>
> Thanks for all the help Martin,
>
> Ian
>
>
>
> Martin Taal wrote:
>> You have to set specific hibernate properties to enable c3p0 (so it is
>> not used by default). See here (and the hibernate manual):
>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>> when you set these properties then hibernate should automatically use
>> c3p0 (provided also that the c3p0 jar is in the classpath).
>> You can pass these properties to the datastore just as the other jdbc
>> properties.
>>
>> Or you can define a datasource to use c3p0. Here is the content of a
>> context.xml file (used in a web app) as an example. In this case
>> hibernate needs to use a datasource instead of a direct jdbc
>> connection driver. See the hibernate manual for more information.
>> <Context path="" privileged="true" antiResourceLocking="false"
>> antiJARLocking="false">
>> <Resource name="jdbc/SupplierControl" auth="Container"
>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>> maxStatementsPerConnection="50"
>> maxIdleTime="86400"
>> numHelperThreads="10"
>> idleConnectionTestPeriod="3600"
>> factory="org.apache.naming.factory.BeanFactory"
>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>> user="sa"
>> password=""
>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>> </Context>
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>
>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>> opens the connection, so I never really deal with them after that. (I
>>> simply create my sessions and transactions as needed).
>>>
>>> Do you have any code snippets for setting up C3P0 with Teneo and how
>>> to get at the properties?
>>>
>>> cheers,
>>> ian
>>>
>>>
>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>> Martin Taal wrote:
>>>> Ian,
>>>> Afaik there can be several reasons why a connection is closed (jdbc
>>>> driver, database). I think mysql has a specific setting for this
>>>> (close connection after so many idle seconds).
>>>> I use connection pooling by c3p0 and it can automatically
>>>> (periodically) test a connection and removes it from the pool if it
>>>> is not valid anymore.
>>>> See here:
>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>
>>>>
>>>> gr. Martin
>>>>
>>>> Ian Bull wrote:
>>>>> Martin,
>>>>>
>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>> stumbled upon this at some point.
>>>>>
>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>> HbDataStore) to determine if the connection is still open?
>>>>>
>>>>> Cheers,
>>>>> Ian
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Timeout after 8 hours [message #103388 is a reply to message #103371] |
Wed, 21 November 2007 06:32 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
Actually, I didn't have the connection_provider or datasource at first.
After I added the C3P0_min_size prop, it started getting slow (so I
thought I would add these, but it didn't make a different) however, I
just added a c3p0-config.xml file to my classpath, (just the default one
they give as an example) and things seem to be working now (I also
rebooted my computer).
So either the xml file, or the reboot seems to have improved things.
Do you know if you need a c3p0-config.xml file? It seems a little
redundant (most the options seem to be available via the properties).
Cheers,
Ian
Martin Taal wrote:
> A quick guess is that it takes so long because you also set the
> datasource property so hibernate will look for a datasource with the
> name you set (the classname), which it won't find.
> Also, I don't think the connection_provider is required.
> So can you try without setting the CONNECTION_PROVIDER and DATASOURCE
> properties?
>
> gr. Martin
>
> Ian Bull wrote:
>> I am doing all my configuration through the properties on the
>> HbDataStore. I now have the following:
>>
>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>> props.setProperty(Environment.USER, "root");
>> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
>> databaseName );
>> props.setProperty(Environment.PASS, password);
>> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>>
>>
>> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>>
>> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>>
>> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
>> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
>> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
>> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
>> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
>> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>>
>> Now when I try to perform any database operations I get:
>>
>> CannotAcquireResourceException: A ResourcePool could not acquire a
>> resource from its primary factory or source.
>>
>> Also, hdbs.initialize takes a long time to complete (before it was < 1
>> second, now it is a minute or two).
>>
>> Thanks for all the help Martin,
>>
>> Ian
>>
>>
>>
>> Martin Taal wrote:
>>> You have to set specific hibernate properties to enable c3p0 (so it
>>> is not used by default). See here (and the hibernate manual):
>>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>>> when you set these properties then hibernate should automatically use
>>> c3p0 (provided also that the c3p0 jar is in the classpath).
>>> You can pass these properties to the datastore just as the other jdbc
>>> properties.
>>>
>>> Or you can define a datasource to use c3p0. Here is the content of a
>>> context.xml file (used in a web app) as an example. In this case
>>> hibernate needs to use a datasource instead of a direct jdbc
>>> connection driver. See the hibernate manual for more information.
>>> <Context path="" privileged="true" antiResourceLocking="false"
>>> antiJARLocking="false">
>>> <Resource name="jdbc/SupplierControl" auth="Container"
>>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>>> maxStatementsPerConnection="50"
>>> maxIdleTime="86400"
>>> numHelperThreads="10"
>>> idleConnectionTestPeriod="3600"
>>> factory="org.apache.naming.factory.BeanFactory"
>>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>>> user="sa"
>>> password=""
>>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>>> </Context>
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>>
>>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>>> opens the connection, so I never really deal with them after that.
>>>> (I simply create my sessions and transactions as needed).
>>>>
>>>> Do you have any code snippets for setting up C3P0 with Teneo and how
>>>> to get at the properties?
>>>>
>>>> cheers,
>>>> ian
>>>>
>>>>
>>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>>> Martin Taal wrote:
>>>>> Ian,
>>>>> Afaik there can be several reasons why a connection is closed (jdbc
>>>>> driver, database). I think mysql has a specific setting for this
>>>>> (close connection after so many idle seconds).
>>>>> I use connection pooling by c3p0 and it can automatically
>>>>> (periodically) test a connection and removes it from the pool if it
>>>>> is not valid anymore.
>>>>> See here:
>>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>>
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ian Bull wrote:
>>>>>> Martin,
>>>>>>
>>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>>> stumbled upon this at some point.
>>>>>>
>>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>>> HbDataStore) to determine if the connection is still open?
>>>>>>
>>>>>> Cheers,
>>>>>> Ian
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Timeout after 8 hours [message #103397 is a reply to message #103388] |
Wed, 21 November 2007 07:50 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Afaik a config.xml or cp30 properties is not required, the hibernate cp30 properties should do. The
hibernate cp30 properties are a subset of all cp30 properties so through the cp30 xml or properties
file you can pass more settings.
gr. Martin
Ian Bull wrote:
> Actually, I didn't have the connection_provider or datasource at first.
> After I added the C3P0_min_size prop, it started getting slow (so I
> thought I would add these, but it didn't make a different) however, I
> just added a c3p0-config.xml file to my classpath, (just the default one
> they give as an example) and things seem to be working now (I also
> rebooted my computer).
>
> So either the xml file, or the reboot seems to have improved things.
>
> Do you know if you need a c3p0-config.xml file? It seems a little
> redundant (most the options seem to be available via the properties).
>
> Cheers,
> Ian
>
>
> Martin Taal wrote:
>> A quick guess is that it takes so long because you also set the
>> datasource property so hibernate will look for a datasource with the
>> name you set (the classname), which it won't find.
>> Also, I don't think the connection_provider is required.
>> So can you try without setting the CONNECTION_PROVIDER and DATASOURCE
>> properties?
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> I am doing all my configuration through the properties on the
>>> HbDataStore. I now have the following:
>>>
>>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>>> props.setProperty(Environment.USER, "root");
>>> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
>>> databaseName );
>>> props.setProperty(Environment.PASS, password);
>>> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>>>
>>>
>>> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>>>
>>> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>>>
>>> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
>>> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
>>> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
>>> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
>>> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
>>> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>>>
>>> Now when I try to perform any database operations I get:
>>>
>>> CannotAcquireResourceException: A ResourcePool could not acquire a
>>> resource from its primary factory or source.
>>>
>>> Also, hdbs.initialize takes a long time to complete (before it was <
>>> 1 second, now it is a minute or two).
>>>
>>> Thanks for all the help Martin,
>>>
>>> Ian
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> You have to set specific hibernate properties to enable c3p0 (so it
>>>> is not used by default). See here (and the hibernate manual):
>>>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>>>> when you set these properties then hibernate should automatically
>>>> use c3p0 (provided also that the c3p0 jar is in the classpath).
>>>> You can pass these properties to the datastore just as the other
>>>> jdbc properties.
>>>>
>>>> Or you can define a datasource to use c3p0. Here is the content of a
>>>> context.xml file (used in a web app) as an example. In this case
>>>> hibernate needs to use a datasource instead of a direct jdbc
>>>> connection driver. See the hibernate manual for more information.
>>>> <Context path="" privileged="true" antiResourceLocking="false"
>>>> antiJARLocking="false">
>>>> <Resource name="jdbc/SupplierControl" auth="Container"
>>>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>>>> maxStatementsPerConnection="50"
>>>> maxIdleTime="86400"
>>>> numHelperThreads="10"
>>>> idleConnectionTestPeriod="3600"
>>>> factory="org.apache.naming.factory.BeanFactory"
>>>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>>>> user="sa"
>>>> password=""
>>>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>>>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>>>> </Context>
>>>>
>>>> gr. Martin
>>>>
>>>> Ian Bull wrote:
>>>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>>>
>>>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>>>> opens the connection, so I never really deal with them after that.
>>>>> (I simply create my sessions and transactions as needed).
>>>>>
>>>>> Do you have any code snippets for setting up C3P0 with Teneo and
>>>>> how to get at the properties?
>>>>>
>>>>> cheers,
>>>>> ian
>>>>>
>>>>>
>>>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>>>> Martin Taal wrote:
>>>>>> Ian,
>>>>>> Afaik there can be several reasons why a connection is closed
>>>>>> (jdbc driver, database). I think mysql has a specific setting for
>>>>>> this (close connection after so many idle seconds).
>>>>>> I use connection pooling by c3p0 and it can automatically
>>>>>> (periodically) test a connection and removes it from the pool if
>>>>>> it is not valid anymore.
>>>>>> See here:
>>>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>>>
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Ian Bull wrote:
>>>>>>> Martin,
>>>>>>>
>>>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>>>> stumbled upon this at some point.
>>>>>>>
>>>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>>>> HbDataStore) to determine if the connection is still open?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Ian
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| | |
Re: [Teneo] Timeout after 8 hours [message #612616 is a reply to message #103294] |
Tue, 20 November 2007 18:42 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
You have to set specific hibernate properties to enable c3p0 (so it is not used by default). See
here (and the hibernate manual):
http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
when you set these properties then hibernate should automatically use c3p0 (provided also that the
c3p0 jar is in the classpath).
You can pass these properties to the datastore just as the other jdbc properties.
Or you can define a datasource to use c3p0. Here is the content of a context.xml file (used in a web
app) as an example. In this case hibernate needs to use a datasource instead of a direct jdbc
connection driver. See the hibernate manual for more information.
<Context path="" privileged="true" antiResourceLocking="false"
antiJARLocking="false">
<Resource name="jdbc/SupplierControl" auth="Container"
maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
maxStatementsPerConnection="50"
maxIdleTime="86400"
numHelperThreads="10"
idleConnectionTestPeriod="3600"
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
user="sa"
password=""
driverClass="net.sourceforge.jtds.jdbc.Driver"
jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
</Context>
gr. Martin
Ian Bull wrote:
> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>
> I'm simply configuring my connection as in [1]. I assume that hbds opens
> the connection, so I never really deal with them after that. (I simply
> create my sessions and transactions as needed).
>
> Do you have any code snippets for setting up C3P0 with Teneo and how to
> get at the properties?
>
> cheers,
> ian
>
>
> [1]http://www.elver.org/hibernate/quick_tutorial.html
> Martin Taal wrote:
>> Ian,
>> Afaik there can be several reasons why a connection is closed (jdbc
>> driver, database). I think mysql has a specific setting for this
>> (close connection after so many idle seconds).
>> I use connection pooling by c3p0 and it can automatically
>> (periodically) test a connection and removes it from the pool if it is
>> not valid anymore.
>> See here:
>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> Martin,
>>>
>>> This isn't really a Teneo question, but I thought maybe you have
>>> stumbled upon this at some point.
>>>
>>> It seems that hibernate (with an MySQL server) closes its connection
>>> after 8 hours of inactivity. Have you ever noticed this? Do you have
>>> any suggestions? Is there a way (given my HbDataStore) to determine
>>> if the connection is still open?
>>>
>>> Cheers,
>>> Ian
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Timeout after 8 hours [message #612622 is a reply to message #103306] |
Wed, 21 November 2007 06:02 |
Ian Bull Messages: 145 Registered: July 2009 |
Senior Member |
|
|
I am doing all my configuration through the properties on the
HbDataStore. I now have the following:
props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
props.setProperty(Environment.USER, "root");
props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
databaseName );
props.setProperty(Environment.PASS, password);
props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
props.setProperty(Environment.C3P0_TIMEOUT, "25200");
props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
props.setProperty(Environment.C3P0_MIN_SIZE, "3");
props.setProperty(Environment.C3P0_MAX_SIZE, "100");
Now when I try to perform any database operations I get:
CannotAcquireResourceException: A ResourcePool could not acquire a
resource from its primary factory or source.
Also, hdbs.initialize takes a long time to complete (before it was < 1
second, now it is a minute or two).
Thanks for all the help Martin,
Ian
Martin Taal wrote:
> You have to set specific hibernate properties to enable c3p0 (so it is
> not used by default). See here (and the hibernate manual):
> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
> when you set these properties then hibernate should automatically use
> c3p0 (provided also that the c3p0 jar is in the classpath).
> You can pass these properties to the datastore just as the other jdbc
> properties.
>
> Or you can define a datasource to use c3p0. Here is the content of a
> context.xml file (used in a web app) as an example. In this case
> hibernate needs to use a datasource instead of a direct jdbc connection
> driver. See the hibernate manual for more information.
> <Context path="" privileged="true" antiResourceLocking="false"
> antiJARLocking="false">
> <Resource name="jdbc/SupplierControl" auth="Container"
> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
> maxStatementsPerConnection="50"
> maxIdleTime="86400"
> numHelperThreads="10"
> idleConnectionTestPeriod="3600"
> factory="org.apache.naming.factory.BeanFactory"
> type="com.mchange.v2.c3p0.ComboPooledDataSource"
> user="sa"
> password=""
> driverClass="net.sourceforge.jtds.jdbc.Driver"
> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
> </Context>
>
> gr. Martin
>
> Ian Bull wrote:
>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>
>> I'm simply configuring my connection as in [1]. I assume that hbds
>> opens the connection, so I never really deal with them after that. (I
>> simply create my sessions and transactions as needed).
>>
>> Do you have any code snippets for setting up C3P0 with Teneo and how
>> to get at the properties?
>>
>> cheers,
>> ian
>>
>>
>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>> Martin Taal wrote:
>>> Ian,
>>> Afaik there can be several reasons why a connection is closed (jdbc
>>> driver, database). I think mysql has a specific setting for this
>>> (close connection after so many idle seconds).
>>> I use connection pooling by c3p0 and it can automatically
>>> (periodically) test a connection and removes it from the pool if it
>>> is not valid anymore.
>>> See here:
>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> Martin,
>>>>
>>>> This isn't really a Teneo question, but I thought maybe you have
>>>> stumbled upon this at some point.
>>>>
>>>> It seems that hibernate (with an MySQL server) closes its connection
>>>> after 8 hours of inactivity. Have you ever noticed this? Do you
>>>> have any suggestions? Is there a way (given my HbDataStore) to
>>>> determine if the connection is still open?
>>>>
>>>> Cheers,
>>>> Ian
>>>
>>>
>
>
|
|
|
Re: [Teneo] Timeout after 8 hours [message #612624 is a reply to message #103360] |
Wed, 21 November 2007 06:15 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
A quick guess is that it takes so long because you also set the datasource property so hibernate
will look for a datasource with the name you set (the classname), which it won't find.
Also, I don't think the connection_provider is required.
So can you try without setting the CONNECTION_PROVIDER and DATASOURCE properties?
gr. Martin
Ian Bull wrote:
> I am doing all my configuration through the properties on the
> HbDataStore. I now have the following:
>
> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
> props.setProperty(Environment.USER, "root");
> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
> databaseName );
> props.setProperty(Environment.PASS, password);
> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>
>
> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>
> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>
> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>
> Now when I try to perform any database operations I get:
>
> CannotAcquireResourceException: A ResourcePool could not acquire a
> resource from its primary factory or source.
>
> Also, hdbs.initialize takes a long time to complete (before it was < 1
> second, now it is a minute or two).
>
> Thanks for all the help Martin,
>
> Ian
>
>
>
> Martin Taal wrote:
>> You have to set specific hibernate properties to enable c3p0 (so it is
>> not used by default). See here (and the hibernate manual):
>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>> when you set these properties then hibernate should automatically use
>> c3p0 (provided also that the c3p0 jar is in the classpath).
>> You can pass these properties to the datastore just as the other jdbc
>> properties.
>>
>> Or you can define a datasource to use c3p0. Here is the content of a
>> context.xml file (used in a web app) as an example. In this case
>> hibernate needs to use a datasource instead of a direct jdbc
>> connection driver. See the hibernate manual for more information.
>> <Context path="" privileged="true" antiResourceLocking="false"
>> antiJARLocking="false">
>> <Resource name="jdbc/SupplierControl" auth="Container"
>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>> maxStatementsPerConnection="50"
>> maxIdleTime="86400"
>> numHelperThreads="10"
>> idleConnectionTestPeriod="3600"
>> factory="org.apache.naming.factory.BeanFactory"
>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>> user="sa"
>> password=""
>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>> </Context>
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>
>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>> opens the connection, so I never really deal with them after that. (I
>>> simply create my sessions and transactions as needed).
>>>
>>> Do you have any code snippets for setting up C3P0 with Teneo and how
>>> to get at the properties?
>>>
>>> cheers,
>>> ian
>>>
>>>
>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>> Martin Taal wrote:
>>>> Ian,
>>>> Afaik there can be several reasons why a connection is closed (jdbc
>>>> driver, database). I think mysql has a specific setting for this
>>>> (close connection after so many idle seconds).
>>>> I use connection pooling by c3p0 and it can automatically
>>>> (periodically) test a connection and removes it from the pool if it
>>>> is not valid anymore.
>>>> See here:
>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>
>>>>
>>>> gr. Martin
>>>>
>>>> Ian Bull wrote:
>>>>> Martin,
>>>>>
>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>> stumbled upon this at some point.
>>>>>
>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>> HbDataStore) to determine if the connection is still open?
>>>>>
>>>>> Cheers,
>>>>> Ian
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Timeout after 8 hours [message #612626 is a reply to message #103371] |
Wed, 21 November 2007 06:32 |
Ian Bull Messages: 145 Registered: July 2009 |
Senior Member |
|
|
Actually, I didn't have the connection_provider or datasource at first.
After I added the C3P0_min_size prop, it started getting slow (so I
thought I would add these, but it didn't make a different) however, I
just added a c3p0-config.xml file to my classpath, (just the default one
they give as an example) and things seem to be working now (I also
rebooted my computer).
So either the xml file, or the reboot seems to have improved things.
Do you know if you need a c3p0-config.xml file? It seems a little
redundant (most the options seem to be available via the properties).
Cheers,
Ian
Martin Taal wrote:
> A quick guess is that it takes so long because you also set the
> datasource property so hibernate will look for a datasource with the
> name you set (the classname), which it won't find.
> Also, I don't think the connection_provider is required.
> So can you try without setting the CONNECTION_PROVIDER and DATASOURCE
> properties?
>
> gr. Martin
>
> Ian Bull wrote:
>> I am doing all my configuration through the properties on the
>> HbDataStore. I now have the following:
>>
>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>> props.setProperty(Environment.USER, "root");
>> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
>> databaseName );
>> props.setProperty(Environment.PASS, password);
>> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>>
>>
>> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>>
>> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>>
>> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
>> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
>> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
>> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
>> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
>> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>>
>> Now when I try to perform any database operations I get:
>>
>> CannotAcquireResourceException: A ResourcePool could not acquire a
>> resource from its primary factory or source.
>>
>> Also, hdbs.initialize takes a long time to complete (before it was < 1
>> second, now it is a minute or two).
>>
>> Thanks for all the help Martin,
>>
>> Ian
>>
>>
>>
>> Martin Taal wrote:
>>> You have to set specific hibernate properties to enable c3p0 (so it
>>> is not used by default). See here (and the hibernate manual):
>>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>>> when you set these properties then hibernate should automatically use
>>> c3p0 (provided also that the c3p0 jar is in the classpath).
>>> You can pass these properties to the datastore just as the other jdbc
>>> properties.
>>>
>>> Or you can define a datasource to use c3p0. Here is the content of a
>>> context.xml file (used in a web app) as an example. In this case
>>> hibernate needs to use a datasource instead of a direct jdbc
>>> connection driver. See the hibernate manual for more information.
>>> <Context path="" privileged="true" antiResourceLocking="false"
>>> antiJARLocking="false">
>>> <Resource name="jdbc/SupplierControl" auth="Container"
>>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>>> maxStatementsPerConnection="50"
>>> maxIdleTime="86400"
>>> numHelperThreads="10"
>>> idleConnectionTestPeriod="3600"
>>> factory="org.apache.naming.factory.BeanFactory"
>>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>>> user="sa"
>>> password=""
>>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>>> </Context>
>>>
>>> gr. Martin
>>>
>>> Ian Bull wrote:
>>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>>
>>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>>> opens the connection, so I never really deal with them after that.
>>>> (I simply create my sessions and transactions as needed).
>>>>
>>>> Do you have any code snippets for setting up C3P0 with Teneo and how
>>>> to get at the properties?
>>>>
>>>> cheers,
>>>> ian
>>>>
>>>>
>>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>>> Martin Taal wrote:
>>>>> Ian,
>>>>> Afaik there can be several reasons why a connection is closed (jdbc
>>>>> driver, database). I think mysql has a specific setting for this
>>>>> (close connection after so many idle seconds).
>>>>> I use connection pooling by c3p0 and it can automatically
>>>>> (periodically) test a connection and removes it from the pool if it
>>>>> is not valid anymore.
>>>>> See here:
>>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>>
>>>>>
>>>>> gr. Martin
>>>>>
>>>>> Ian Bull wrote:
>>>>>> Martin,
>>>>>>
>>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>>> stumbled upon this at some point.
>>>>>>
>>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>>> HbDataStore) to determine if the connection is still open?
>>>>>>
>>>>>> Cheers,
>>>>>> Ian
>>>>>
>>>>>
>>>
>>>
>
>
|
|
|
Re: [Teneo] Timeout after 8 hours [message #612627 is a reply to message #103388] |
Wed, 21 November 2007 07:50 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Afaik a config.xml or cp30 properties is not required, the hibernate cp30 properties should do. The
hibernate cp30 properties are a subset of all cp30 properties so through the cp30 xml or properties
file you can pass more settings.
gr. Martin
Ian Bull wrote:
> Actually, I didn't have the connection_provider or datasource at first.
> After I added the C3P0_min_size prop, it started getting slow (so I
> thought I would add these, but it didn't make a different) however, I
> just added a c3p0-config.xml file to my classpath, (just the default one
> they give as an example) and things seem to be working now (I also
> rebooted my computer).
>
> So either the xml file, or the reboot seems to have improved things.
>
> Do you know if you need a c3p0-config.xml file? It seems a little
> redundant (most the options seem to be available via the properties).
>
> Cheers,
> Ian
>
>
> Martin Taal wrote:
>> A quick guess is that it takes so long because you also set the
>> datasource property so hibernate will look for a datasource with the
>> name you set (the classname), which it won't find.
>> Also, I don't think the connection_provider is required.
>> So can you try without setting the CONNECTION_PROVIDER and DATASOURCE
>> properties?
>>
>> gr. Martin
>>
>> Ian Bull wrote:
>>> I am doing all my configuration through the properties on the
>>> HbDataStore. I now have the following:
>>>
>>> props.setProperty(Environment.DRIVER, "com.mysql.jdbc.Driver");
>>> props.setProperty(Environment.USER, "root");
>>> props.setProperty(Environment.URL, "jdbc:mysql://127.0.0.1:3306/" +
>>> databaseName );
>>> props.setProperty(Environment.PASS, password);
>>> props.setProperty(Environment.DIALECT,org.hibernate.dialect. MySQLInnoDBDialect.class.getName());
>>>
>>>
>>> props.setProperty(Environment.CONNECTION_PROVIDER,C3P0Connec tionProvider.class.getName());
>>>
>>> props.setProperty(Environment.DATASOURCE,ComboPooledDataSour c.class.getName());
>>>
>>> props.setProperty(Environment.C3P0_ACQUIRE_INCREMENT, "1");
>>> props.setProperty(Environment.C3P0_TIMEOUT, "25200");
>>> props.setProperty(Environment.C3P0_MAX_STATEMENTS, "50");
>>> props.setProperty(Environment.C3P0_IDLE_TEST_PERIOD, "14400");
>>> props.setProperty(Environment.C3P0_MIN_SIZE, "3");
>>> props.setProperty(Environment.C3P0_MAX_SIZE, "100");
>>>
>>> Now when I try to perform any database operations I get:
>>>
>>> CannotAcquireResourceException: A ResourcePool could not acquire a
>>> resource from its primary factory or source.
>>>
>>> Also, hdbs.initialize takes a long time to complete (before it was <
>>> 1 second, now it is a minute or two).
>>>
>>> Thanks for all the help Martin,
>>>
>>> Ian
>>>
>>>
>>>
>>> Martin Taal wrote:
>>>> You have to set specific hibernate properties to enable c3p0 (so it
>>>> is not used by default). See here (and the hibernate manual):
>>>> http://www.mchange.com/projects/c3p0/index.html#hibernate-sp ecific
>>>> when you set these properties then hibernate should automatically
>>>> use c3p0 (provided also that the c3p0 jar is in the classpath).
>>>> You can pass these properties to the datastore just as the other
>>>> jdbc properties.
>>>>
>>>> Or you can define a datasource to use c3p0. Here is the content of a
>>>> context.xml file (used in a web app) as an example. In this case
>>>> hibernate needs to use a datasource instead of a direct jdbc
>>>> connection driver. See the hibernate manual for more information.
>>>> <Context path="" privileged="true" antiResourceLocking="false"
>>>> antiJARLocking="false">
>>>> <Resource name="jdbc/SupplierControl" auth="Container"
>>>> maxPoolSize="100" minPoolSize="1" acquireIncrement="1"
>>>> maxStatementsPerConnection="50"
>>>> maxIdleTime="86400"
>>>> numHelperThreads="10"
>>>> idleConnectionTestPeriod="3600"
>>>> factory="org.apache.naming.factory.BeanFactory"
>>>> type="com.mchange.v2.c3p0.ComboPooledDataSource"
>>>> user="sa"
>>>> password=""
>>>> driverClass="net.sourceforge.jtds.jdbc.Driver"
>>>> jdbcUrl="jdbc:jtds:sqlserver://192.168.189.138/ls3_l"/>
>>>> </Context>
>>>>
>>>> gr. Martin
>>>>
>>>> Ian Bull wrote:
>>>>> Is Teneo using C3P0 by default, or do I have to configure it to do so?
>>>>>
>>>>> I'm simply configuring my connection as in [1]. I assume that hbds
>>>>> opens the connection, so I never really deal with them after that.
>>>>> (I simply create my sessions and transactions as needed).
>>>>>
>>>>> Do you have any code snippets for setting up C3P0 with Teneo and
>>>>> how to get at the properties?
>>>>>
>>>>> cheers,
>>>>> ian
>>>>>
>>>>>
>>>>> [1]http://www.elver.org/hibernate/quick_tutorial.html
>>>>> Martin Taal wrote:
>>>>>> Ian,
>>>>>> Afaik there can be several reasons why a connection is closed
>>>>>> (jdbc driver, database). I think mysql has a specific setting for
>>>>>> this (close connection after so many idle seconds).
>>>>>> I use connection pooling by c3p0 and it can automatically
>>>>>> (periodically) test a connection and removes it from the pool if
>>>>>> it is not valid anymore.
>>>>>> See here:
>>>>>> http://www.mchange.com/projects/c3p0/index.html#configuring_ connection_testing
>>>>>>
>>>>>>
>>>>>> gr. Martin
>>>>>>
>>>>>> Ian Bull wrote:
>>>>>>> Martin,
>>>>>>>
>>>>>>> This isn't really a Teneo question, but I thought maybe you have
>>>>>>> stumbled upon this at some point.
>>>>>>>
>>>>>>> It seems that hibernate (with an MySQL server) closes its
>>>>>>> connection after 8 hours of inactivity. Have you ever noticed
>>>>>>> this? Do you have any suggestions? Is there a way (given my
>>>>>>> HbDataStore) to determine if the connection is still open?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Ian
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Goto Forum:
Current Time: Sun Oct 06 10:49:32 GMT 2024
Powered by FUDForum. Page generated in 0.05273 seconds
|