Ejemplo n.º 1
0
        public virtual bool isTablePresent(string tableName)
        {
            tableName = prependDatabaseTablePrefix(tableName);
            Connection connection = null;

            try
            {
                connection = sqlSession.Connection;
                DatabaseMetaData databaseMetaData = connection.MetaData;
                ResultSet        tables           = null;

                string schema = this.connectionMetadataDefaultSchema;
                if (!string.ReferenceEquals(dbSqlSessionFactory.DatabaseSchema, null))
                {
                    schema = dbSqlSessionFactory.DatabaseSchema;
                }

                string databaseType = dbSqlSessionFactory.DatabaseType;

                if (DbSqlSessionFactory.POSTGRES.Equals(databaseType))
                {
                    tableName = tableName.ToLower();
                }

                try
                {
                    tables = databaseMetaData.getTables(this.connectionMetadataDefaultCatalog, schema, tableName, JDBC_METADATA_TABLE_TYPES);
                    return(tables.next());
                }
                finally
                {
                    if (tables != null)
                    {
                        tables.close();
                    }
                }
            }
            catch (Exception e)
            {
                throw LOG.checkDatabaseTableException(e);
            }
        }