@Override public Meta meta() { return delegate.meta(); }
public class ExportAsInsert { public static void main(String[] args) { try (DSLContext ctx = DSL.using(url, user, password)) { ctx.meta() .getSchemas() .stream() // Filter out those schemas that you want to export .filter(schema -> schema.getName().equals("TEST")) // Get the tables for each schema... .flatMap(schema -> schema.getTables().stream()) // ... and format their content as INSERT statements. .forEach(table -> System.out.println(ctx.fetch(table).formatInsert())); } } }
public void update() { tables = new LinkedHashMap<>(); cachedTables = new LinkedHashMap<>(); for (Table<?> table : dsl.meta().getTables()) { if (!(table.toString().startsWith(tablePrefix))) { // table not in current catalog or schema continue; } tables.put(table.getName(), table); } }
@Override public CheckResult check() { try (Connection conn = datasource.getConnection()) { if (!context.get(conn).meta().getSchemas().contains(DEFAULT_CATALOG.ZIPKIN)) { throw new IllegalStateException("Zipkin schema is missing"); } } catch (SQLException | RuntimeException e) { return CheckResult.failed(e); } return CheckResult.OK; }
public static boolean tableExists(DSLContext context, Table table) { for (Table t : context.meta().getTables()) { if (t.getName().equalsIgnoreCase(table.getName())) { return true; } } return false; } }
private List<Schema> getSchemasFromMeta() { if (schemas == null) { schemas = new ArrayList<Schema>(); for (Schema schema : create().meta().getSchemas()) if (getInputSchemata().contains(schema.getName())) schemas.add(schema); } return schemas; }
public MappingQueryGenerator(DSLContext dslContext, final String tableName) { Meta meta = dslContext.meta(); for (Table table : meta.getTables()) { System.out.println(table.getName()); if (table.getName().equalsIgnoreCase(tableName)) { this.table = table; break; } } if (this.table == null) { throw new JDBCSinkException("Table not found: " + tableName); } }
ParserImpl(Configuration configuration) { this.dsl = DSL.using(configuration); this.metaLookups = configuration.settings().getParseWithMetaLookups(); this.meta = metaLookups == IGNORE_ON_FAILURE || metaLookups == THROW_ON_FAILURE ? dsl.meta() : null; }
if (context.meta().getTables().stream() .filter(t -> t.getName().equals(recordTable.getName())) .findFirst()
@Override public void clear(Class component) throws DaoException { if (!tableExists()) { return; } DSLContext context = getJooq(); try { if (!context.meta().getTables().contains(Tables.META_INFO)) { return; } context.delete(Tables.META_INFO) .where(Tables.META_INFO.COMPONENT.eq(component.getSimpleName())) .execute(); } finally { freeJooq(context); } }
existingTables = context.meta().getTables().stream() .map(t -> t.getName().toLowerCase(Locale.ENGLISH)) .collect(Collectors.toSet());
MySQLTorodbMeta( String databaseName, DSLContext dsl, DatabaseInterface databaseInterface, @Nonnull Provider<SubDocType.Builder> subDocTypeBuilderProvider) throws SQLException, IOException, InvalidDatabaseException { this.databaseName = databaseName; this.databaseInterface = databaseInterface; this.subDocTypeBuilderProvider = subDocTypeBuilderProvider; Meta jooqMeta = dsl.meta(); Connection conn = dsl.configuration().connectionProvider().acquire(); DatabaseMetaData jdbcMeta = conn.getMetaData(); //only system executor thread can update this map collectionSchemes = new MapMaker().concurrencyLevel(1).makeMap(); TorodbSchema.TORODB.checkOrCreate(dsl, jooqMeta, jdbcMeta, databaseInterface); loadAllCollectionSchemas(dsl, jooqMeta, jdbcMeta); createTables(conn, jdbcMeta); createProcedures(conn, jdbcMeta); dsl.configuration().connectionProvider().release(conn); }
PostgreSQLTorodbMeta( String databaseName, DSLContext dsl, DatabaseInterface databaseInterface, @Nonnull Provider<SubDocType.Builder> subDocTypeBuilderProvider) throws SQLException, IOException, InvalidDatabaseException { this.databaseName = databaseName; this.databaseInterface = databaseInterface; this.subDocTypeBuilderProvider = subDocTypeBuilderProvider; Meta jooqMeta = dsl.meta(); Connection conn = dsl.configuration().connectionProvider().acquire(); DatabaseMetaData jdbcMeta = conn.getMetaData(); //only system executor thread can update this map collectionSchemes = new MapMaker().concurrencyLevel(1).makeMap(); TorodbSchema.TORODB.checkOrCreate(dsl, jooqMeta, jdbcMeta, databaseInterface); loadAllCollectionSchemas(dsl, jooqMeta, jdbcMeta); createTypes(conn, jdbcMeta); createProcedures(conn, jdbcMeta); dsl.configuration().connectionProvider().release(conn); }
GreenplumTorodbMeta( String databaseName, DSLContext dsl, DatabaseInterface databaseInterface, @Nonnull Provider<SubDocType.Builder> subDocTypeBuilderProvider) throws SQLException, IOException, InvalidDatabaseException { this.databaseName = databaseName; this.databaseInterface = databaseInterface; this.subDocTypeBuilderProvider = subDocTypeBuilderProvider; Meta jooqMeta = dsl.meta(); Connection conn = dsl.configuration().connectionProvider().acquire(); DatabaseMetaData jdbcMeta = conn.getMetaData(); //only system executor thread can update this map collectionSchemes = new MapMaker().concurrencyLevel(1).makeMap(); TorodbSchema.TORODB.checkOrCreate(dsl, jooqMeta, jdbcMeta, databaseInterface); loadAllCollectionSchemas(dsl, jooqMeta, jdbcMeta); createTypes(conn, jdbcMeta); createProcedures(conn, jdbcMeta); dsl.configuration().connectionProvider().release(conn); }
&& dsl.meta().getSchemas().stream().noneMatch( s -> schema.getName().equalsIgnoreCase( s.getName() ) ) )