JDBC and Multithreading

前端 未结 3 489
栀梦
栀梦 2021-02-04 19:19

I am trying to run few queries using a multithreaded approach, however I think I am doing something wrong because my program takes about five minute to run a simple select state

3条回答
  •  北海茫月
    2021-02-04 19:48

    One Connection can only execute one query at a time. You need multiple connections available to execute database operations in parallel. Try using a DataSource with a connection pool, and make each thread request a connection from the pool.

提交回复
热议问题