title: java.sql.SQLException: Io exception: Connection reset by peer: socket write error
body: <p>I am using oracle 11g,hibernate 3 and jsf2.I deployed my application on was7.Every thing is going well but when i try to login after 5-6 hours it is gives me error</p>
  
  <pre><code>ERROR org.hibernate.util.JDBCExceptionReporter - Io exception: Connection reset by peer: socket write error
  [5/28/13 11:31:25:048 IST] 00000024 SystemErr     R org.hibernate.exception.GenericJDBCException: could not execute query
      at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.loader.Loader.doList(Loader.java:2231)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
      at org.hibernate.loader.Loader.list(Loader.java:2120)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
  </code></pre>
  
  <p>I unable to find out how this error to solve.Please help me.Thanks in advance.</p>
  
  <p>Now i have solved this problem by code but i don'nt know is it proper way or not.will you suggest me, i should continue with this solution on not.</p>
  
  <pre><code>public class ApplicationUtilityBean implements Serializable {
  private SessionFactory sessionFactory;
  private AnnotationConfiguration cfg;
  public String filePath;
  private String realPath = Config.PATH;
  
  public ApplicationUtilityBean() throws URISyntaxException {
      getConnection();
  }
  
  public void getConnection() {
      URL r = this.getClass().getClassLoader().getResource("hibernate.cfg.xml");
              cfg = new AnnotationConfiguration();
      cfg.configure(r);
      String pwd = cfg.getProperty("hibernate.connection.password");
      TripleDESEncryption tripledesenc = null;
      try {
          tripledesenc = new TripleDESEncryption();
      } catch (Exception e) {
          e.printStackTrace();
      }
      cfg.setProperty("hibernate.connection.password",
              tripledesenc.decrypt(pwd));
      sessionFactory = cfg.buildSessionFactory();
  
      System.out.println("cfg: " + cfg);
      System.out.println("sessionFactory: " + sessionFactory);
  }
  
  public Session getSession() {
      System.out.println("Going to get session");
      Session session = null;
      try {
          System.out.println("cfg is: " + cfg);
          System.out.println("sessionFactory: " + sessionFactory);
          session = sessionFactory.openSession();
          if(session != null){
              try {
                  Transaction trxn = session.beginTransaction();
                  Query queryResult = session.createSQLQuery("select * from dual");
                  List&lt;GTS_USER&gt;listgtsuser = queryResult.list();     
                                  } catch (Exception e) {                 
                  e.printStackTrace();
                  System.out.println("Creating new connection............");
                  session.close();
                  sessionFactory.close();
                  getConnection();
                  session = sessionFactory.openSession();
              }
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
      return session;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and my hibernate config file is</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
  &lt;session-factory&gt;
  
      &lt;property name="hibernate.cache.region.factory_class"&gt;net.sf.ehcache.hibernate.EhCacheRegionFactory&lt;/property&gt;
      &lt;property name="hibernate.cache.use_query_cache"&gt;true&lt;/property&gt;
      &lt;property name="hibernate.cache.use_second_level_cache"&gt;true&lt;/property&gt;
  
      &lt;property name="hibernate.connection.driver_class"&gt;oracle.jdbc.OracleDriver&lt;/property&gt;
      &lt;property name="hibernate.connection.url"&gt;jdbc:oracle:thin:@xxxxxxxxx:1521:HMS&lt;/property&gt;
      &lt;property name="hibernate.connection.username"&gt;xxxxx&lt;/property&gt;
      &lt;property name="hibernate.connection.password"&gt;xxxxxxxxxxx&lt;/property&gt;
      &lt;property name="hibernate.connection.pool_size"&gt;10&lt;/property&gt; 
      &lt;property name="show_sql"&gt;true&lt;/property&gt;
      &lt;property name="dialect"&gt;org.hibernate.dialect.OracleDialect&lt;/property&gt;
      &lt;property name="hibernate.hbm2ddl.auto"&gt;update&lt;/property&gt;
  </code></pre>