Hi all

One customer reported a problem to us, that they are getting the following
error message:

com.ibatis.dao.client.DaoException: Error executing
query for object.  Cause: java.sql.SQLException: Io exception: Connection
reset by peer: socket write error

The cause is a restart of the Database while the application is still
running.

The transactionManager is configured via
 <transactionManager type="JDBC" >
        <dataSource type="JNDI">
                <property name="DataSource"
value="java:comp/env/jdbc/dataSourceName"/>
        </dataSource>
 </transactionManager>


Oracle suggest something like the following, when using TopLink, to
reestablish a connection:

        if (clientSession != null)
                        db = clientSession;

                if (db == null || !db.isConnected()) {

                        logger.info("Login Info:  trying to connect to
ClientSession ...");

                        ServerSession server = (ServerSession)
getToplinkServer();
                        db = server.acquireClientSession();
                        db.connect();
                        clientSession = db;
                }

                db.setExceptionHandler(new ExceptionHandler() {
                        public Object handleException(RuntimeException
exception) {
                                if (logger.isDebugEnabled()) {
        
logger.debug("handleException(RuntimeException) - start");
                                }

                                if ((exception instanceof DatabaseException)
                                                &&
(exception.toString().indexOf(
                                                                "onnection
reset by peer") > 0)) {
                                        DatabaseException dbex =
(DatabaseException) exception;
        
dbex.getAccessor().reestablishConnection(dbex.getSession());
                                        serverSession = null;
                                        clientSession = null;
                                        Object returnObject =
dbex.getSession().executeQuery(
                                                        dbex.getQuery());
        
return returnObject;
                                }

                                return null;
                        }
                });

                clientSession = db;
                return db;

How can this be done with iBatis??

Any suggestions would be appreciated.

Thanx, Andre

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to