示例#1
0
 public TableCache(Database dbObj)
 {
     this._tableArray = new Hashtable();
     this._db = dbObj;
     // Load the table cache for the given database.
     deserializeCache();
 }
示例#2
0
        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;
        }
示例#3
0
 public ProviderMSSQL2000(Database dbObj)
 {
     this._dbObj = dbObj;
 }
示例#4
0
        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;
            }
        }
示例#5
0
 public QueryBuilder(Database dbObject)
     : this()
 {
     this._assocDBObject = dbObject;
 }
示例#6
0
 public ProviderACCESS(Database dbObj)
 {
     this._dbObj = dbObj;
 }
示例#7
0
 public void setDatabaseObject(Database dbObject)
 {
     this._dbProvider = dbObject;
 }
示例#8
0
 public ATable(string name, Database dbProvider)
     : this(name)
 {
     this._dbProvider = dbProvider;
 }
示例#9
0
 public ProviderMYSQL(Database dbObj)
 {
     this._dbObj = dbObj;
 }
示例#10
0
 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;
 }
示例#11
0
 public ProviderSQLITE(Database dbObj)
 {
     this._dbObj = dbObj;
 }
示例#12
0
        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;
        }
示例#13
0
 public ProviderORACLE(Database dbObj)
 {
     this._dbObj = dbObj;
 }