Java Mybatis3 PoolDataSource as Singletone
up vote
0
down vote
favorite
i made simple program that connect with Postgresql, to select data from database.
i set 5 thread to select database and i use PoolDataSource default setting.
DAO class is singletone, SqlsessionFactory also same, Sqlsession is method scope.
ExecutorService service = Executors.newFixedThreadPool(5);
service.submit(()->{
//select each another table
});
and i saw stacktrace in Jconsole.
one thread approach popConnection method in PoolDataSource, another thread was wait.
and one thread approach query execute method in Postgresql, another thread was wait.
i think that database connection must be synchronized.
but only one thread can approach query execute?
there is no way to execute query same time with another thread?
or this cause is PoolDataSource made as singleton?
Thanks.
java multithreading mybatis java-threads
add a comment |
up vote
0
down vote
favorite
i made simple program that connect with Postgresql, to select data from database.
i set 5 thread to select database and i use PoolDataSource default setting.
DAO class is singletone, SqlsessionFactory also same, Sqlsession is method scope.
ExecutorService service = Executors.newFixedThreadPool(5);
service.submit(()->{
//select each another table
});
and i saw stacktrace in Jconsole.
one thread approach popConnection method in PoolDataSource, another thread was wait.
and one thread approach query execute method in Postgresql, another thread was wait.
i think that database connection must be synchronized.
but only one thread can approach query execute?
there is no way to execute query same time with another thread?
or this cause is PoolDataSource made as singleton?
Thanks.
java multithreading mybatis java-threads
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of thejstack -p you_process_id
which shows this?
– Roman Konoval
Nov 16 at 8:33
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i made simple program that connect with Postgresql, to select data from database.
i set 5 thread to select database and i use PoolDataSource default setting.
DAO class is singletone, SqlsessionFactory also same, Sqlsession is method scope.
ExecutorService service = Executors.newFixedThreadPool(5);
service.submit(()->{
//select each another table
});
and i saw stacktrace in Jconsole.
one thread approach popConnection method in PoolDataSource, another thread was wait.
and one thread approach query execute method in Postgresql, another thread was wait.
i think that database connection must be synchronized.
but only one thread can approach query execute?
there is no way to execute query same time with another thread?
or this cause is PoolDataSource made as singleton?
Thanks.
java multithreading mybatis java-threads
i made simple program that connect with Postgresql, to select data from database.
i set 5 thread to select database and i use PoolDataSource default setting.
DAO class is singletone, SqlsessionFactory also same, Sqlsession is method scope.
ExecutorService service = Executors.newFixedThreadPool(5);
service.submit(()->{
//select each another table
});
and i saw stacktrace in Jconsole.
one thread approach popConnection method in PoolDataSource, another thread was wait.
and one thread approach query execute method in Postgresql, another thread was wait.
i think that database connection must be synchronized.
but only one thread can approach query execute?
there is no way to execute query same time with another thread?
or this cause is PoolDataSource made as singleton?
Thanks.
java multithreading mybatis java-threads
java multithreading mybatis java-threads
asked Nov 15 at 1:55
KJ HEY
93
93
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of thejstack -p you_process_id
which shows this?
– Roman Konoval
Nov 16 at 8:33
add a comment |
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of thejstack -p you_process_id
which shows this?
– Roman Konoval
Nov 16 at 8:33
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of the
jstack -p you_process_id
which shows this?– Roman Konoval
Nov 16 at 8:33
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of the
jstack -p you_process_id
which shows this?– Roman Konoval
Nov 16 at 8:33
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53311341%2fjava-mybatis3-pooldatasource-as-singletone%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you positive that threads are waiting for the connection from the pool and not on the response from the DB? Can you share an output of the
jstack -p you_process_id
which shows this?– Roman Konoval
Nov 16 at 8:33