Пример #1
0
        internal virtual void CreateTable()
        {
            string query = string.Empty;

            try
            {
                IConnection conn = SQLConnection.GetConnection();
                if (DBTableExists())
                {
                    if (deleteExisting)
                    {
                        System.Console.Out.WriteLine("deleting table " + tableName);
                        IStatement stmt = conn.CreateStatement();
                        query = "drop table " + tableName;
                        stmt.Execute(query);
                        stmt.Close();
                        IStatement stmtindex = conn.CreateStatement();
                        query = "DROP INDEX IF EXISTS " + tableName + "_index";
                        stmtindex.Execute(query);
                        stmtindex.Close();
                    }
                }
                System.Console.Out.WriteLine("creating table " + tableName);
                IStatement stmt_1 = conn.CreateStatement();
                //query = "create table  IF NOT EXISTS " + tableName + " (\"sentid\" text, \"tokenid\" int, \"patterns\" bytea); ";
                query = "create table IF NOT EXISTS " + tableName + " (sentid text, patterns bytea); ";
                stmt_1.Execute(query);
                stmt_1.Close();
                conn.Close();
            }
            catch (SQLException e)
            {
                throw new Exception("Error executing query " + query + "\n" + e);
            }
        }