-->
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.  [ 2 posts ] 
Author Message
 Post subject: session.createSQLQuery give me a java.net.SocketException
PostPosted: Fri Apr 13, 2012 7:35 pm 
Newbie

Joined: Fri Apr 13, 2012 4:46 pm
Posts: 1
Hello there im trying to use this query on Hibernate 3.6.8 with Spring:

@Override
public List searchProducto(final String claves,final Integer pagina, final Integer nroFilas) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
String sql = "SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY RANK DESC) AS RowNr, * FROM vista_web_productos AS vwp INNER JOIN FREETEXTTABLE( producto,clave,:name) as ftt ON ftt.[KEY]=vwp.id_web) t WHERE RowNr BETWEEN :inicio AND :fin";
SQLQuery query = (SQLQuery) session.createSQLQuery(sql);
query.addEntity(VistaWebProductoVO.class).setString("name",claves).setInteger("inicio", ((pagina - 1) * nroFilas)+1 ).setInteger("fin", ((pagina) * nroFilas) );
List list = query.list();
return list;
}
});
}

Whe i test this code, sometimes it works and sometimes it doesnt. But when I compile my project the test always fail giving me a :java.net.SocketException: Connection reset by peer: socket write error. This is the stack error:


-------------------------------------------------------------------------------
Test set: TestSuite
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 5.212 sec <<< FAILURE!
pruebaDataAccess(pe.com.estilos.portal.dataaccess.VistaWebTest) Time elapsed: 0.708 sec <<< FAILURE!
org.springframework.dao.DataAccessResourceFailureException: could not execute query; nested exception is org.hibernate.exception.JDBCConnectionException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:629)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
at pe.com.estilos.portal.dataaccess.domain.hibernate.HibernateVistaWebProductoDAO.searchProducto(HibernateVistaWebProductoDAO.java:249)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy27.searchProducto(Unknown Source)
at pe.com.estilos.portal.dataaccess.VistaWebTest.pruebaDataAccess(VistaWebTest.java:38)
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2545)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at pe.com.estilos.portal.dataaccess.domain.hibernate.HibernateVistaWebProductoDAO$1.doInHibernate(HibernateVistaWebProductoDAO.java:254)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 42 more
Caused by: java.sql.SQLException: I/O Error: Connection reset by peer: socket write error
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1053)
at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:465)
at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:776)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
... 50 more
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.DataOutputStream.write(DataOutputStream.java:90)
at net.sourceforge.jtds.jdbc.SharedSocket.sendNetPacket(SharedSocket.java:676)
at net.sourceforge.jtds.jdbc.RequestStream.putPacket(RequestStream.java:560)
at net.sourceforge.jtds.jdbc.RequestStream.flush(RequestStream.java:508)
at net.sourceforge.jtds.jdbc.TdsCore.executeSQL(TdsCore.java:1040)
... 57 more


Any ideas of what is happening?


Top
 Profile  
 
 Post subject: Re: session.createSQLQuery give me a java.net.SocketException
PostPosted: Sun Apr 15, 2012 5:47 pm 
Beginner
Beginner

Joined: Fri Jan 29, 2010 8:17 pm
Posts: 20
Location: Portland OR
That doesn't look like a hibernate issue. Either the connection was never successfully created, or there is an issue with your DB on the server side. With Oracle I've seen 'connection reset' errors occur for various reasons:
- The table you are using can't allocate more space or the database in general is out of space
- Core dumps from Oracle bugs for certain types of queries
- Firewalls snapping connections, etc

I'd look to see if you see any errors in your DB's log. Or ask a DBA to take a look. But having no experience with SQLServer or jtds I don't have much more in the way of troubleshooting advice to offer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.