Results 1 to 7 of 7

Thread: Help!! Spring and Hibernate sessions

  1. #1
    Join Date
    Jan 2010
    Posts
    78

    Help!! Spring and Hibernate sessions

    Here we are trying to solve a problem and hope someone can help us because, if a Java application (not used in Tomcat) over the weekend, then on Monday morning, the sessions and connections in the pool are "dead". The first request then provides an exception like "java.sql.SQLException: I / O Error: Connection reset by peer: socket write error". The only solution so far: Restarting application in Tomcat. The whole has been configured using Spring with a session Factory (LocalSessionFactoryBean), TransactionManager (HibernateTransactionManager) and data source (JndiObjectFactoryBean). This combination works great so long to be regularly removed from the client requests and therefore still a valid session or connection is available.

  2. #2
    Join Date
    Jan 2006
    Posts
    211

    Re: Help!! Spring and Hibernate sessions

    Hello Fragant,
    You can create discardConnection and then create new one after weekend task with the quartz. You should keep in mind that every half an hour during weekend it should send one to select DBServer. I am sure that will help you.

  3. #3
    Join Date
    Jan 2010
    Posts
    78

    Re: Help!! Spring and Hibernate sessions

    Thank you for the answer!! No mySQL, but MS-SQL Server 2005. I'm sorry, of course, was worth mentioning ... As a JDBC driver is used jTDS 0.9.1. I could probably take one's own Transaction Manager, which inherited the original manager, and intercept the exception is explicit, but I suspect that it will go well with available materials (such as discardConnectionAndCreateNewOneAfterWeekend = true). Please continue to help.

  4. #4
    Join Date
    Jan 2009
    Posts
    140

    Re: Help!! Spring and Hibernate sessions

    The coding that is mentioned below may help you :
    Code:
    '! - Data Source -> 
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> 
    <property name="driverClassName"> <value> jdbc.driverClassName $ () </ value> </ property> 
    <property name="url"> <value> jdbc.url $ () </ value> </ property> 
    <property name="username"> <value> jdbc.username $ () </ value> </ property> 
    <property name="password"> <value> jdbc.password $ () </ value> </ property> 
    <property name="validationQuery"> <value> jdbc.validationQuery $ () </ value> </ property> 
    <property name="maxActive"> <value> jdbc.maxActive $ () </ value> </ property> 
    '/ Bean>
    The "ValidationQuery" is something like "select 1", and database-specific. The important thing is that it works to your DB and that it is fast.

  5. #5
    Join Date
    Jan 2009
    Posts
    143

    Re: Help!! Spring and Hibernate sessions

    Even I think that the coding given by the "RichiRich", can really prove useful for you. The mechanism works as follows :
    1. Connection is retrieved from the pool
    2. The ValidationQuery is tested, whether they are still "alive"
    3. If not, the exception is caught, the connection is discarded, a new one is created (in effect a reconnect) and inserted into the pool
    4. The functioning Connection is returned

    The reason is - always with the restriction that I can remember / have seen - that it is not possible with JDBC, see a connection, whether they come to an end 'is. The only possible test is to do a query with the Connection.

  6. #6
    Join Date
    Mar 2008
    Posts
    672

    Re: Help!! Spring and Hibernate sessions

    My guess based on intuition-only: Connections in the pool have a timeout (database side): when they exceed this, they will be closed from database side. The pool gets the big time with ... If this is true then should be the connection pool configures better - such as hanging by the pool, and documented, there is probably enough to ...

  7. #7
    Join Date
    Nov 2008
    Posts
    996

    Re: Help!! Spring and Hibernate sessions

    Here again are the final solution. The Property "validationQuery" there is not with us because we use the class as a data source JndiObjectFactoryBean. For the Connection using JNDI lookup on a container managed connection pool is concerned. Instead, one can in the Tomcat context.xml or context where the resource was configured, insert the attribute "validationQuery"
    Code:
     <Resource name = "jdbc / jndiname" 
    auth = "Container" 
    type = "javax.sql.DataSource" 
    username = "sa" 
    password = "XXX" 
    Driver Class Name = "net.sourceforge.jtds.jdbc.Driver" 
    url = "jdbc: jTDS: sqlserver: / / HOSTNAME / DBNAME; NamedPipes = false; instance = MSSMLBIZ" 
    validationQuery = "select 1" 
    maxActive = "8" 
    maxIdle = "4" />

Similar Threads

  1. What is PHP sessions and how they function
    By Zavier in forum Software Development
    Replies: 5
    Last Post: 23-01-2010, 02:30 AM
  2. What is Spring?
    By Adrina_g in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 01:56 PM
  3. Why Spring, Benefits using spring framework?
    By Mahendra varma in forum Software Development
    Replies: 3
    Last Post: 25-04-2009, 10:27 AM
  4. How to set sessions for checkboxes
    By RogerFielden in forum Software Development
    Replies: 3
    Last Post: 15-04-2009, 02:07 PM
  5. SBS 2008 - Multiple RDP Sessions?
    By Oscar M in forum Small Business Server
    Replies: 3
    Last Post: 10-03-2009, 03:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,534,734.90281 seconds with 17 queries