WONDERFUL Lukas, Your are the greatest !!

I have been using settings and that works well for my case.  In case this  
helps someone else I am documenting what I did.

I have many identical database schemas created using settings in the below 
helper method

        public static Settings getSettings( String specificDatabase ) {
            String schemaInput = "dashboard2";
            Settings settings = new Settings()
                .withRenderMapping(new RenderMapping()
                .withSchemata(
                    new MappedSchema().withInput(schemaInput)
                    .withOutput(specificDatabase)
                )
            );
            return settings;
        }

Based on your help the following retrieves the specific database being used

        public static String getDatabaseNameFromDsl(DSLContext dsl) {
            Settings settings = dsl.settings();
            return 
settings.getRenderMapping().getSchemata().get(0).getOutput();
        }        

Thanks again,
Jim
On Thursday, March 18, 2021 at 4:54:16 AM UTC-4 [email protected] wrote:

> Hi Jim,
>
> Please use a different DSLContext (and backing Configuration) with a 
> different Settings instance for each database as documented here:
>
> https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-render-mapping/
>
> You can create derived configurations using Configuration.derive(Settings) 
> for that purpose, but do note that each time you derive a Configuration, 
> the internal caches (e.g. used for reflection of into(Class) calls) may be 
> flushed. Chances are, you'll have separate JDBC connections, though, one 
> per database, and with separate connections, you might have a separate 
> beans (e.g. if you're using Spring), and you can inject the appropriate 
> Settings once for each bean.
>
> I hope this helps,
> Lukas
>
> On Wed, Mar 17, 2021 at 8:31 PM Jim McGlaughlin <[email protected]> 
> wrote:
>
>> Hello,
>>
>> I am using the same schemata for several databases using 
>> 'outputSchemaToDefault'.
>>
>> At runtime I would like to get the specific database the DSLContext is 
>> connected to.
>>
>> In a debugger I can see that info is stored in 
>>
>> configuration.settings.renderMapping.schemata.0.output
>>
>> Is the a method of the DSLConext to retrieve this?  I would like to avoid 
>> having to pass this value through layers of code which are already carrying 
>> the DSLContext.
>>
>> Thanks,
>> Jim
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jooq-user/2ba8d594-e59d-4e11-b130-177a41479b8fn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jooq-user/2ba8d594-e59d-4e11-b130-177a41479b8fn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/4de3c4c5-7ce6-49ae-b72a-b438aaaab430n%40googlegroups.com.

Reply via email to