@Override public void close() { RuntimeException closeError = null; if (transferList != null) { synchronized (this) { for (Transfer transfer : transferList) { try { traceOperation("SESSION_CLOSE", 0); transfer.writeInt(SessionRemote.SESSION_CLOSE); done(transfer); transfer.close(); } catch (RuntimeException e) { trace.error(e, "close"); closeError = e; } catch (Exception e) { trace.error(e, "close"); } } } transferList = null; } traceSystem.close(); if (embedded != null) { embedded.close(); embedded = null; } if (closeError != null) { throw closeError; } }
/** Close a connection. */ void close() { try { stop = true; closeSession(); } catch (Exception e) { server.traceError(e); } finally { transfer.close(); trace("Close"); server.remove(this); } }
/** * Cancel the statement with the given id. * * @param id the statement id */ public void cancelStatement(int id) { for (Transfer transfer : transferList) { try { Transfer trans = transfer.openNewConnection(); trans.init(); trans.writeInt(clientVersion); trans.writeInt(clientVersion); trans.writeString(null); trans.writeString(null); trans.writeString(sessionId); trans.writeInt(SessionRemote.SESSION_CANCEL_STATEMENT); trans.writeInt(id); trans.close(); } catch (IOException e) { trace.debug(e, "could not cancel statement"); } } }
private Transfer initTransfer(ConnectionInfo ci, String db, String server) throws IOException { Socket socket = NetUtils.createSocket(server, Constants.DEFAULT_TCP_PORT, ci.isSSL()); Transfer trans = new Transfer(this); trans.setSocket(socket); trans.setSSL(ci.isSSL()); trans.init(); trans.writeInt(Constants.TCP_PROTOCOL_VERSION_6); trans.writeInt(Constants.TCP_PROTOCOL_VERSION_15); trans.writeString(db); trans.writeString(ci.getOriginalURL()); trans.writeString(ci.getUserName()); trans.writeBytes(ci.getUserPasswordHash()); trans.writeBytes(ci.getFilePasswordHash()); String[] keys = ci.getKeys(); trans.writeInt(keys.length); for (String key : keys) { trans.writeString(key).writeString(ci.getProperty(key)); } try { done(trans); clientVersion = trans.readInt(); trans.setVersion(clientVersion); if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_14) { if (ci.getFileEncryptionKey() != null) { trans.writeBytes(ci.getFileEncryptionKey()); } } trans.writeInt(SessionRemote.SESSION_SET_ID); trans.writeString(sessionId); done(trans); if (clientVersion >= Constants.TCP_PROTOCOL_VERSION_15) { autoCommit = trans.readBoolean(); } else { autoCommit = true; } return trans; } catch (DbException e) { trans.close(); throw e; } }