/// <exception cref="Java.Sql.SQLException"/>
 public static bool ExistsTable(string tablename)
 {
     if (existingTablenames == null)
     {
         existingTablenames = new HashSet <string>();
         IDatabaseMetaData md = connection.GetMetaData();
         IResultSet        rs = md.GetTables(null, null, "%", null);
         while (rs.Next())
         {
             existingTablenames.Add(rs.GetString(3).ToLower());
         }
     }
     return(existingTablenames.Contains(tablename.ToLower()));
 }
Exemplo n.º 2
0
 //  /**
 //   * not yet supported if backed by DB
 //   * @return
 //   */
 //  public Set<Map.Entry<String, Map<Integer, Set<Integer>>>> entrySet() {
 //    if(!useDBForTokenPatterns)
 //      return patternsForEachToken.entrySet();
 //    else
 //      //not yet supported if backed by DB
 //      throw new UnsupportedOperationException();
 //  }
 public virtual bool DBTableExists()
 {
     try
     {
         IConnection conn = null;
         conn = SQLConnection.GetConnection();
         IDatabaseMetaData dbm    = conn.GetMetaData();
         IResultSet        tables = dbm.GetTables(null, null, tableName, null);
         if (tables.Next())
         {
             System.Console.Out.WriteLine("Found table " + tableName);
             conn.Close();
             return(true);
         }
         conn.Close();
         return(false);
     }
     catch (SQLException e)
     {
         throw new Exception(e);
     }
 }