Question regarding servlet lifecycle and connection pooling ..

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Question regarding servlet lifecycle and connection pooling ..

John Dale
Greetings;

We've wrapped my connection pool interface in a Factory.  Can you
confirm how the current request's thread is used by JDBC connection
pooling to MySQL?

Sincerely,

John

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Question regarding servlet lifecycle and connection pooling ..

Christopher Schultz-2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

John,

On 7/25/20 11:25, John Dale wrote:
> We've wrapped my connection pool interface in a Factory.  Can you
> confirm how the current request's thread is used by JDBC
> connection pooling to MySQL?

Are you using Tomcat to manage your DataSource resource? For example:

Context ctx = new InitialContext();

DataSource ds =
(DataSource)ctx.lookup("java:/comp/env/jdbc/myDataSource");

Connection conn = ds.getConnection();

?

If you have written your own datasource factory, then when you call
ctx.lookup(), you will be getting the DataSource object returned by
your factory when your web application starts.

If you make calls to DataSource.getConnection,
Connection.prepareStatement, etc. everything is done in the current
thread. If you use Tomcat's tomcat-pool or DBCP2, the only things that
happen outside of the current request-processing thread are the
background maintenance tasks such as checking for abandoned connections.

Does that answer your question?

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAl8e+8oACgkQHPApP6U8
pFihVQ/9H1gtRafA2J5+m0WtgsM7SGVnzbBnPsHpu6Fu58Z+7qK5Ds4sx1OVLoZq
PlZa33mZ73MzaLJ5fQh7CI6/dKdl+k6Vst5gkejV+sWvmWnKZuA5t+8+emxecgVg
aYU08BLQeblLMqPUp9gjYpaoqgFgpe6EYkE8zQIY63nWAp30yHUW45QPMm0vdtAM
gNnUEAHgggMSyTwvrqFlBwxjDJThe4WUS934wg+VsS4CyUvtkg0i97DMoS1FWabH
Ipaw7//XKdT63MXI25gJHvo8D3Tu0OPAWJGoqWycFuO6iOpz9gijctnYfWawOOaX
6JvBGH3hYdf2W/qisnnklI6Ips8sSuwwBKzTPcB1ZJGptyJnavi2/LULxqgsE+AY
yQGCcj4JFgpf65qOrwo4bBzVS3U+kc+VB9AjUoNQBSyLMmoiq+/8OFx83yT+g/Fr
Qt34+b28W49TOzF4v7KFmSVPBlJ40pQIgS7R04RD5aPeNqYkVn0BUmav05q4fTe+
lp3nAcRCfpJMG3T4TDTtHH24xT2WeC3+wyhOyP3QlsYML8yMO6MGOfYCW6wN0jlM
muZMCHYlnkZ+xZqaQ9GU6qqL2WhClf8v9Xjw/ppClSr+D8Cx4JXdTKXhO9QUKb0j
TyvkHD35UwGcDlQduqyiUQb5tpOC2Ym5vjsZFbmTwbZeKE39zmk=
=gT2X
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Question regarding servlet lifecycle and connection pooling ..

Mark Thomas-2
In reply to this post by John Dale
On July 25, 2020 3:25:18 PM UTC, John Dale <[hidden email]> wrote:

>Greetings;
>
>We've wrapped my connection pool interface in a Factory.  Can you
>confirm how the current request's thread is used by JDBC connection
>pooling to MySQL?
>
>Sincerely,
>
>John
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]

It depends. What type of request (sync or async), which connection pool, etc. You need to ask a more specific question.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]