protected override void SendCreateToBuffer(DatabaseParameterBuffer dpb, string database) { this.Write(IscCodes.op_create); this.Write(0); dpb.Append(IscCodes.isc_dpb_utf8_filename, 0); this.WriteBuffer(Encoding.UTF8.GetBytes(database)); this.WriteBuffer(dpb.ToArray()); }
protected override void SendAttachToBuffer(DatabaseParameterBuffer dpb, string database) { // Attach to the database this.Write(IscCodes.op_attach); this.Write(0); // Database object ID dpb.Append(IscCodes.isc_dpb_utf8_filename, 0); this.WriteBuffer(Encoding.UTF8.GetBytes(database)); // Database PATH this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer }
public override void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { #if (!LINUX) lock (this.SyncObject) { try { using (SSPIHelper sspiHelper = new SSPIHelper()) { byte[] authData = sspiHelper.InitializeClientSecurity(); SendTrustedAuthToBuffer(dpb, authData); SendAttachToBuffer(dpb, database); this.Flush(); IResponse response = this.ReadResponse(); ProcessTrustedAuthResponse(sspiHelper, ref response); ProcessAttachResponse((GenericResponse)response); } } catch (IOException) { try { this.Detach(); } catch (Exception) { } throw new IscException(IscCodes.isc_net_write_err); } // Get server version this.serverVersion = this.GetServerVersion(); } #else throw new NotSupportedException(); #endif }
public override void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { #if (!LINUX) lock (SyncObject) { try { using (SSPIHelper sspiHelper = new SSPIHelper()) { byte[] authData = sspiHelper.InitializeClientSecurity(); SendTrustedAuthToBuffer(dpb, authData); SendAttachToBuffer(dpb, database); XdrStream.Flush(); IResponse response = ReadResponse(); ProcessTrustedAuthResponse(sspiHelper, ref response); ProcessAttachResponse((GenericResponse)response); } } catch (IscException) { SafelyDetach(); throw; } catch (IOException ex) { SafelyDetach(); throw IscException.ForErrorCode(IscCodes.isc_net_write_err, ex); } AfterAttachActions(); } #else throw new NotSupportedException(); #endif }
public virtual void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this.SyncObject) { try { SendAttachToBuffer(dpb, database); this.Flush(); ProcessAttachResponse(this.ReadGenericResponse()); } catch (IscException) { SafelyDetach(); throw; } catch (IOException) { SafelyDetach(); throw new IscException(IscCodes.isc_net_write_err); } AfterAttachActions(); } }
public void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { throw new NotSupportedException("Trusted Auth isn't supported on External Engine."); }
public void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { }
public void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { byte[] databaseBuffer = Encoding.Default.GetBytes(database); int dbHandle = 0; // Clear status vector ClearStatusVector(); _fbClient.isc_attach_database( _statusVector, (short)databaseBuffer.Length, databaseBuffer, ref dbHandle, (short)dpb.Length, dpb.ToArray()); ParseStatusVector(_statusVector); // Update the database handle _handle = dbHandle; // Get server version _serverVersion = GetServerVersion(); } }
public void CreateDatabase(DatabaseParameterBuffer dpb) { IDatabase db = ClientFactory.CreateDatabase(this.options.ServerType); db.CreateDatabase(dpb, this.options.DataSource, this.options.Port, this.options.Database); }
protected virtual void SendAttachToBuffer(DatabaseParameterBuffer dpb, string database) { // Attach to the database this.Write(IscCodes.op_attach); this.Write(0); // Database object ID this.WriteBuffer(Encoding.Default.GetBytes(database)); // Database PATH this.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer }
public void CreateDatabase(DatabaseParameterBuffer dpb) { IDatabase db = ClientFactory.CreateDatabase(_options); db.CreateDatabase(dpb, _options.DataSource, _options.Port, _options.Database); }
public static void CreateDatabase(Hashtable values) { bool overwrite = false; int index = 0; byte dialect = 3; int serverType = 0; if (!values.ContainsKey("User") || !values.ContainsKey("Password") || !values.ContainsKey("Database")) { throw new ArgumentException("CreateDatabase requires a user name, password and database path."); } if (values.ContainsKey("ServerType")) { serverType = Convert.ToInt32(values["ServerType"], CultureInfo.InvariantCulture); } if (!values.ContainsKey("DataSource")) { values.Add("DataSource", "localhost"); } if (!values.ContainsKey("Port")) { values.Add("Port", 3050); } if (values.ContainsKey("Dialect")) { dialect = Convert.ToByte(values["Dialect"], CultureInfo.InvariantCulture); } if (dialect < 1 || dialect > 3) { throw new ArgumentException("Incorrect database dialect it should be 1, 2, or 3."); } if (values.ContainsKey("Overwrite")) { overwrite = (bool)values["Overwrite"]; } try { // Configure Attachment FbConnectionStringBuilder csb = new FbConnectionStringBuilder(); csb.DataSource = values["DataSource"].ToString(); csb.UserID = values["User"].ToString(); csb.Password = values["Password"].ToString(); csb.Database = values["Database"].ToString(); csb.Port = Convert.ToInt32(values["Port"], CultureInfo.InvariantCulture); csb.ServerType = serverType; FbConnectionString options = new FbConnectionString(csb); // DPB configuration DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); // Dpb version dpb.Append(IscCodes.isc_dpb_version1); // Dummy packet interval dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); // User name dpb.Append(IscCodes.isc_dpb_user_name, values["User"].ToString()); // User password dpb.Append(IscCodes.isc_dpb_password, values["Password"].ToString()); // Database dialect dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { dialect, 0, 0, 0 }); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (short)(overwrite ? 1 : 0)); // Character set if (values.ContainsKey("Charset")) { index = Charset.SupportedCharsets.IndexOf(values["Charset"].ToString()); if (index == -1) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append( IscCodes.isc_dpb_set_db_charset, Charset.SupportedCharsets[index].Name); } } // Page Size if (values.ContainsKey("PageSize")) { dpb.Append(IscCodes.isc_dpb_page_size, Convert.ToInt32(values["PageSize"], CultureInfo.InvariantCulture)); } // Forced writes if (values.ContainsKey("ForcedWrite")) { dpb.Append(IscCodes.isc_dpb_force_write, (short)((bool)values["ForcedWrite"] ? 1 : 0)); } if (!overwrite) { try { // Check if the database exists FbConnectionInternal check = new FbConnectionInternal(options); check.Connect(); check.Disconnect(); IscException ex = new IscException(IscCodes.isc_db_or_file_exists); throw new FbException(ex.Message, ex); } catch (Exception) { throw; } } // Create the new database FbConnectionInternal c = new FbConnectionInternal(options); c.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
/// <include file='Doc/en_EN/FbConnection.xml' path='doc/class[@name="FbConnection"]/method[@name="CreateDatabase(System.String,System.Int32,System.Boolean,System.Boolean)"]/*'/> public static void CreateDatabase( string connectionString, int pageSize, bool forcedWrites, bool overwrite) { FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { // DPB configuration DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); // Dpb version dpb.Append(IscCodes.isc_dpb_version1); // Dummy packet interval dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); // User name dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); // User password dpb.Append(IscCodes.isc_dpb_password, options.Password); // Database dialect dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 }); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (short)(overwrite ? 1 : 0)); // Character set if (options.Charset.Length > 0) { int index = Charset.SupportedCharsets.IndexOf(options.Charset); if (index == -1) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append( IscCodes.isc_dpb_set_db_charset, Charset.SupportedCharsets[index].Name); } } // Page Size if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } // Forced writes dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); if (!overwrite) { // Check if the database exists FbConnectionInternal c = new FbConnectionInternal(options); try { c.Connect(); c.Disconnect(); IscException ex = new IscException(IscCodes.isc_db_or_file_exists); throw new FbException(ex.Message, ex); } catch (FbException ex) { if (ex.ErrorCode != 335544344) { throw; } } } // Create the new database FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
public void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { int[] statusVector = FesConnection.GetNewStatusVector(); int dbHandle = 0; FbClient.isc_attach_database( statusVector, (short)database.Length, database, ref dbHandle, (short)dpb.Length, dpb.ToArray()); this.handle = dbHandle; this.ParseStatusVector(statusVector); // Get server version this.serverVersion = this.GetServerVersion(); } }
public void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { int[] statusVector = FesConnection.GetNewStatusVector(); int dbHandle = this.Handle; FbClient.isc_create_database( statusVector, (short)database.Length, database, ref dbHandle, (short)dpb.Length, dpb.ToArray(), 0); this.ParseStatusVector(statusVector); this.handle = dbHandle; this.Detach(); } }
public virtual void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { throw new NotSupportedException("Trusted Auth isn't supported on < FB2.1."); }
public virtual void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this.SyncObject) { try { SendCreateToBuffer(dpb, database); this.Flush(); try { ProcessCreateResponse(this.ReadGenericResponse()); this.Detach(); } catch (IscException) { try { this.CloseConnection(); } catch { } throw; } } catch (IOException) { throw new IscException(IscCodes.isc_net_write_err); } } }
protected virtual void SendTrustedAuthToBuffer(DatabaseParameterBuffer dpb, byte[] authData) { dpb.Append(IscCodes.isc_dpb_trusted_auth, authData); }
protected virtual void SendCreateToBuffer(DatabaseParameterBuffer dpb, string database) { this.Write(IscCodes.op_create); this.Write(0); this.WriteBuffer(Encoding.Default.GetBytes(database)); this.WriteBuffer(dpb.ToArray()); }
public virtual void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (SyncObject) { try { SendCreateToBuffer(dpb, database); XdrStream.Flush(); try { ProcessCreateResponse(ReadGenericResponse()); Detach(); } catch (IscException) { try { CloseConnection(); } catch { } throw; } } catch (IOException ex) { throw IscException.ForErrorCode(IscCodes.isc_net_write_err, ex); } } }
public void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { byte[] databaseBuffer = Encoding.Default.GetBytes(database); int dbHandle = Handle; // Clear status vector ClearStatusVector(); _fbClient.isc_create_database( _statusVector, (short)databaseBuffer.Length, databaseBuffer, ref dbHandle, (short)dpb.Length, dpb.ToArray(), 0); ParseStatusVector(_statusVector); _handle = dbHandle; Detach(); } }
private DatabaseParameterBuffer BuildDpb(IDatabase db, FbConnectionString options) { DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); dpb.Append(IscCodes.isc_dpb_version1); dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { Convert.ToByte(options.Dialect), 0, 0, 0 }); dpb.Append(IscCodes.isc_dpb_lc_ctype, options.Charset); if (options.DbCachePages > 0) { dpb.Append(IscCodes.isc_dpb_num_buffers, options.DbCachePages); } if (!string.IsNullOrEmpty(options.Role)) { dpb.Append(IscCodes.isc_dpb_sql_role_name, options.Role); } dpb.Append(IscCodes.isc_dpb_connect_timeout, options.ConnectionTimeout); if (!options.FallIntoTrustedAuth) { dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); dpb.Append(IscCodes.isc_dpb_password, options.Password); } dpb.Append(IscCodes.isc_dpb_process_id, GetProcessId()); dpb.Append(IscCodes.isc_dpb_process_name, GetProcessName()); if (options.NoDatabaseTriggers) { dpb.Append(IscCodes.isc_dpb_no_db_triggers, 1); } if (options.NoGarbageCollect) { dpb.Append(IscCodes.isc_dpb_no_garbage_collect, (byte)0); } return dpb; }
public void AttachWithTrustedAuth(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { throw new NotImplementedException("Trusted Auth isn't supported on Embedded Firebird."); }
public void CreateDatabase(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { try { this.connection.Connect(dataSource, port, this.packetSize, this.charset); this.Send.Write(IscCodes.op_create); this.Send.Write((int)0); this.Send.Write(database); this.Send.WriteBuffer(dpb.ToArray()); this.Send.Flush(); try { this.handle = this.ReadGenericResponse().ObjectHandle; this.Detach(); } catch (IscException) { try { this.connection.Disconnect(); } catch (Exception) { } throw; } } catch (IOException) { throw new IscException(IscCodes.isc_net_write_err); } } }
public void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { int dbHandle = 0; // Clear status vector this.ClearStatusVector(); lock (this) { SafeNativeMethods.isc_get_current_database(this.statusVector, ref dbHandle); this.handle = dbHandle; } }
public void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this) { try { this.connection.Connect(dataSource, port, this.packetSize, this.charset); this.Identify(database); this.Send.Write(IscCodes.op_attach); this.Send.Write((int)0); // Database object ID this.Send.Write(database); // Database PATH this.Send.WriteBuffer(dpb.ToArray()); // DPB Parameter buffer this.Send.Flush(); try { this.handle = this.ReadGenericResponse().ObjectHandle; } catch (IscException) { try { this.connection.Disconnect(); } catch { } throw; } } catch (IOException) { this.connection.Disconnect(); throw new IscException(IscCodes.isc_net_write_err); } // Get server version this.serverVersion = this.GetServerVersion(); } }
public static void CreateDatabase(string connectionString, int pageSize, bool forcedWrites, bool overwrite) { FbConnectionString options = new FbConnectionString(connectionString); options.Validate(); try { // DPB configuration DatabaseParameterBuffer dpb = new DatabaseParameterBuffer(); // Dpb version dpb.Append(IscCodes.isc_dpb_version1); // Dummy packet interval dpb.Append(IscCodes.isc_dpb_dummy_packet_interval, new byte[] { 120, 10, 0, 0 }); // User name dpb.Append(IscCodes.isc_dpb_user_name, options.UserID); // User password dpb.Append(IscCodes.isc_dpb_password, options.Password); // Database dialect dpb.Append(IscCodes.isc_dpb_sql_dialect, new byte[] { options.Dialect, 0, 0, 0 }); // Character set if (options.Charset.Length > 0) { Charset charset = Charset.GetCharset(options.Charset); if (charset == null) { throw new ArgumentException("Character set is not valid."); } else { dpb.Append(IscCodes.isc_dpb_set_db_charset, charset.Name); } } // Forced writes dpb.Append(IscCodes.isc_dpb_force_write, (short)(forcedWrites ? 1 : 0)); // Database overwrite dpb.Append(IscCodes.isc_dpb_overwrite, (overwrite ? 1 : 0)); // Page Size if (pageSize > 0) { dpb.Append(IscCodes.isc_dpb_page_size, pageSize); } // Create the new database FbConnectionInternal db = new FbConnectionInternal(options); db.CreateDatabase(dpb); } catch (IscException ex) { throw new FbException(ex.Message, ex); } }
public virtual void Attach(DatabaseParameterBuffer dpb, string dataSource, int port, string database) { lock (this.SyncObject) { try { SendAttachToBuffer(dpb, database); this.Flush(); ProcessAttachResponse(this.ReadGenericResponse()); } catch (IOException) { try { this.Detach(); } catch (Exception) { } throw new IscException(IscCodes.isc_net_write_err); } // Get server version this.serverVersion = this.GetServerVersion(); } }