public TableCache(Database dbObj) { this._tableArray = new Hashtable(); this._db = dbObj; // Load the table cache for the given database. deserializeCache(); }
public TransactionQueue(Database parent) { dbParent = parent; SQLConsole.Data.LLDBA.SERVERINFO svrinfo; svrinfo = parent.GetDatabaseConnector().svrinfo; this._dbo = parent; this._dbo.DBEvent_ReconnectingCloseCause += new Database.ReconnectingCloseCause(_dbo_DBEvent_ReconnectingCloseCause); this._transList = new System.Collections.ArrayList(); this.Atomic = true; this.AutoExecute = false; this.odt = null; this.oc = null; this._errorState = 0; this._lastID = -1; }
public ProviderMSSQL2000(Database dbObj) { this._dbObj = dbObj; }
public bool Parse() { try { //Fix for mysql. if (this._dbo.GetDatabaseConnector().getDBType() == DATABASETYPES.MYSQL) { this._dbo.GetDatabaseConnector().executeNonQuery("SET AUTOCOMMIT = 0"); this._dbo.GetDatabaseConnector().executeNonQuery("BEGIN"); } odt = this._dbo.GetDatabaseConnector().GetRawConnectionObject().BeginTransaction(); this.oc = new OdbcCommand(); oc.Connection = odt.Connection; oc.Transaction = odt; foreach (string sql in this._transList) { //string tmpsql = this._dbo.CompileSQLToNative(sql); string tmpsql = sql; if ((tmpsql != "") && tmpsql.Length > 2) { if (this._dbo.GetDatabaseConnector().Open() != ERRORCODES.NONE) { throw (new Exception("Database connection lost.")); } oc.CommandText = this._dbo.GetDatabaseConnector().DoTopLevelSqlTranslations(ref tmpsql); oc.ExecuteNonQuery(); } } odt.Commit(); if (this._dbo.GetDatabaseConnector().getDBType() == DATABASETYPES.MYSQL) this._dbo.GetDatabaseConnector().executeNonQuery("COMMIT"); return true; } catch(Exception e) { if(e.Message.IndexOf("parallel transactions") > 0) { // Start new connection and try again. this._dbo = this._dbo.getNewConnection(); this.Parse(); } if(this.dbParent.GetDatabaseConnector().GetRawConnectionObject().State == ConnectionState.Closed) this.dbParent.RaiseDBCloseClause(); try { odt.Rollback(); if (this._dbo.GetDatabaseConnector().getDBType() == DATABASETYPES.MYSQL) this._dbo.GetDatabaseConnector().executeNonQuery("ROLLBACK"); } catch { /**/ } this._errorState = 1; this._errorString = e.Message; return false; } }
public QueryBuilder(Database dbObject) : this() { this._assocDBObject = dbObject; }
public ProviderACCESS(Database dbObj) { this._dbObj = dbObj; }
public void setDatabaseObject(Database dbObject) { this._dbProvider = dbObject; }
public ATable(string name, Database dbProvider) : this(name) { this._dbProvider = dbProvider; }
public ProviderMYSQL(Database dbObj) { this._dbObj = dbObj; }
public Database getNewConnection() { Database newDB = new Database(new LLDBA()); newDB.GetDatabaseConnector().svrinfo = this.GetDatabaseConnector().svrinfo; newDB.Open(); newDB.UseDatabase(newDB.GetDatabaseConnector().svrinfo._database); return newDB; }
public ProviderSQLITE(Database dbObj) { this._dbObj = dbObj; }
public static QueryBuilder CreateQueryBuilder(string csql, Database dbObj) { // This function will create a querybuilder object from commonsql QueryBuilder newQuery = new QueryBuilder(dbObj); // normalize commonsql: int offset = 0; int iQuote = 0; if (csql.IndexOf(";") <= 0) csql += ";"; for (int i = 0; i < (csql.Length-offset); i++) { if (csql[i] == '\'' && iQuote == 0) iQuote = 1; else if (csql[i] == '\'' && iQuote == 1) { if(csql[i-1] != '\'' && csql[i-1] != '\\') iQuote = 0; } else if (iQuote == 0) { if ((csql[i + offset].Equals('(') || csql[i + offset].Equals(')')) && (!csql[(i + offset) - 1].Equals(' '))) { // space to the left csql = csql.Insert((i + (offset++)), " "); } if ((csql[i + offset].Equals('(') || csql[i + offset].Equals(')')) && (!csql[(i + offset) + 1].Equals(' '))) { // space to the left csql = csql.Insert((i + (offset++)) + 1, " "); } } } // endnormalize string[] sqlStatements = csql.Split(';'); foreach (string sqlStr in sqlStatements) { if (!sqlStr.Trim().Equals("")) { //if (sqlStr.Substring(sqlStr.Length - 1).Equals(";")) // sqlStr = sqlStr.Substring(0, sqlStr.Length - 1); string[] tokens = sqlStr.Split(' '); switch (tokens[0].ToLower()) { case "drop": if (tokens[1].ToLower().Equals("table")) newQuery.setType(ABSTRACTQUERYTYPES.DropQuery); if (tokens[1].ToLower().Equals("database")) newQuery.setType(ABSTRACTQUERYTYPES.DropQuery); newQuery.addSource(tokens[2].ToLower()); newQuery.addField(new AField("droptype", tokens[1].ToLower())); break; case "insert": insertQueryHandler(ref newQuery, sqlStr); break; case "delete": deleteQueryHandler(ref newQuery, sqlStr); break; case "show": break; case "select": selectQueryHandler(ref newQuery, sqlStr); break; case "update": updateQueryHandler(ref newQuery, sqlStr); break; case "alter": alterQueryHandler(ref newQuery, sqlStr); break; } } } return newQuery; }
public ProviderORACLE(Database dbObj) { this._dbObj = dbObj; }