Hi all, I would just like to make sure that I'm not understanding things wrongly, so here's my current setup:
Some backend exposes web services and has some layer of management functions providing configs etc., including a pair of a DSLContext using a JDBC-connection per request. Each request has its own pair of DSLContext and JDBC-connection, though. Concepts like transactions are bound to the scope of one entire request by default. > return DSL.using > ( > this.jdbc, SQLDialect.valueOf(dialect), > new JooqSettingsLoader(this.config).load() > ); Am I correct that this approach is at least safe to use with one thread processing one request? Am I correct that this approach is still safe when the request spawns additional threads to query the database and all those threads use the same DSLContext, same JDBC-connection etc.? Transactions are NOT managed by those individual threads and statements won't be reused as well. So it reads like from a JDBC point of view, reusing the connection is safe: https://docs.oracle.com/javadb/10.8.3.0/devguide/cdevconcepts89498.html Resuing a DSLContext seems to be sage as well: >> Can I use the singleton pattern to use it? > Yes, that's the recommended approach https://github.com/jOOQ/jOOQ/issues/7410#issuecomment-380454662 OTOH, there are some old discussions on the mailing list that make me wonder if I'm wrong: https://groups.google.com/forum/#!topic/jooq-user/VK7KQcjj3Co The reason I'm somewhat sure to need to share one connection is that I have queries in the backend providing results using temporary tables within the scope of one request. This way different queries within the same request, though basing data on each other, don't necessarily re-execute the same queries over and over again. But that only works with temp-tables using a shared connection. Multiple threads are useful, because not all queries are based on each other if they are, I implemented some locking to only create temp-tables ones on my own. So is there something fundamentally wrong in my assumptions? Thanks! Mit freundlichen Grüßen, Thorsten Schöning -- Thorsten Schöning E-Mail: [email protected] AM-SoFT IT-Systeme http://www.AM-SoFT.de/ Telefon...........05151- 9468- 55 Fax...............05151- 9468- 88 Mobil..............0178-8 9468- 04 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow -- 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/246742075.20200605114453%40am-soft.de.
