/// <summary> /// Constructs a new <c>HsqlTcpClient</c> instance /// with the given host, port, etc. /// </summary> /// <param name="host">The server host name or IP address.</param> /// <param name="port">The server listen port.</param> /// <param name="path">The database remote open path. (presently unused/unsupported)</param> /// <param name="database">The server alias for one of its mounted databases</param> /// <param name="tls">The Transport Layer Security flag</param> /// <param name="user">The initial database user name.</param> /// <param name="password">The initial database user password.</param> /// <exception cref="HsqlException"> /// </exception> internal HsqlTcpClient( string host, int port, string path, string database, bool tls, string user, string password) { m_host = host; m_port = port; m_path = path; m_database = database; m_tls = tls; InitializeInstance(); InitializeConnection(host, port, tls); Request loginRequest = m_Protocol.CreateTcpClientLoginRequest( user, password, database); Response loginResponse = Session.execute(loginRequest); if (loginResponse.isError()) { throw Trace.error(loginResponse); } m_sessionId = m_Protocol.GetSessionId(loginResponse); m_databaseId = m_Protocol.GetDatabaseId(loginResponse); }
public HsqlDataReader(org.hsqldb.Result result) { if (result == null) { throw new ArgumentNullException("result"); } else if (result.isError()) { throw new HsqlDataSourceException(result); } else if (result.isUpdateCount()) { m_recordsAffected = result.getUpdateCount(); } else if (result.isData()) { m_recordsAffected = -1; m_result = result; m_fieldCount = result.getColumnCount(); m_metaData = result.metaData; m_columnTypes = m_metaData.colTypes; } else { throw new InvalidOperationException( "Unhandled Result Mode: " + result.mode); } }
/// <summary> /// Gets the value of the session attribute with the given identifier. /// </summary> /// <param name="attributeId">The attribute identifier.</param> /// <returns>The attribute value</returns> private object GetAttribute(int attributeId) { m_Protocol.SetType(m_request, RequestType.GETSESSIONATTR); Response response = Session.execute(m_request); if (response.isError()) { throw Trace.error(response); } switch (attributeId) { case SessionInfo.INFO_AUTOCOMMIT: { return(m_Protocol.GetAttributeAutoCommit(response)); } case SessionInfo.INFO_CONNECTION_READONLY: { return(m_Protocol.GetAttributeConnectionReadOnly( response)); } case SessionInfo.INFO_DATABASE: { return(m_Protocol.GetAttributeDatabase(response)); } case SessionInfo.INFO_DATABASE_READONLY: { return(m_Protocol.GetAttributeDatabaseReadOnly( response)); } case SessionInfo.INFO_ISOLATION: { return(m_Protocol.GetAttributeIsolation(response)); } case SessionInfo.INFO_USER: { return(m_Protocol.GetAttributeUser(response)); } default: { throw new ArgumentException( "attributeId", "Unknown Attribute Id: " + attributeId); } } }
/// <summary> /// Sets the value of the attribute denoted by the given identifier. /// </summary> /// <param name="value">The attribute value.</param> /// <param name="attributeId">The attribute identifier.</param> /// <exception cref="HsqlException"> /// </exception> private void SetAttribute(object value, int attributeId) { m_Protocol.SetType(m_request, RequestType.SETSESSIONATTR); m_Protocol.ClearAttributes(m_request); switch (attributeId) { case SessionInfo.INFO_AUTOCOMMIT: { m_Protocol.SetAttributeAutoCommit( m_request, (bool)value); break; } case SessionInfo.INFO_CONNECTION_READONLY: { m_Protocol.SetAttributeConnectionReadOnly( m_request, (bool)value); break; } case SessionInfo.INFO_ISOLATION: { m_Protocol.SetAttributeIsolation( m_request, (int)value); break; } default: { throw new System.ArgumentException( "attributeId", "Invalid Attribute Id: " + attributeId); } } Response response = Session.execute(m_request); if (response.isError()) { throw Trace.error(response); } }
/// <summary> /// Resets this session. /// </summary> /// <remarks> /// Used to reset the remote session object. In case of /// failure, the underlying TPC connection is physically /// closed. When a pooled database connection's close() /// method is called, it should delegate to this method /// instead of ISession.close() and return this object /// to the pool upon success. In this way, a remote session /// proxy object can be reused with no further /// initialisation. /// </remarks> /// <exception cref="HsqlException"> /// </exception> void ISession.resetSession() { Request request = new Request(RequestType.HSQLRESETSESSION); Response response = Session.execute(request); if (response.isError()) { m_closed = true; CloseConnection(); throw Trace.error(response); } m_sessionId = m_Protocol.GetSessionId(response); m_databaseId = m_Protocol.GetDatabaseId(response); }
/// <summary> /// Executes the specified request. /// </summary> /// <param name="request">The request.</param> /// <returns> /// The result of executing the specified request. /// </returns> internal Response Execute(Request request) { try { Response response = m_session.execute(request); if (response.isError()) { throw new HsqlDataSourceException(response); } return(response); } catch (HsqlException e) { throw new HsqlDataSourceException(e); } }