This problem occurs with a small probability. My business scenario is like this: start a timer and execute a select statement every 30 seconds to get data from the MySQL database. However, the following problems sometimes occur:
Asked
Active
Viewed 331 times
0
-
1Could you also post some code? – Aliics Aug 10 '22 at 02:49
-
1Does this answer your question [What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it?](https://stackoverflow.com/questions/5554734/what-causes-a-java-lang-arrayindexoutofboundsexception-and-how-do-i-prevent-it) – sorifiend Aug 10 '22 at 03:12
-
I found a solution to the problem. This problem is caused by my SqlSession being shared by multiple threads. If you encounter similar problems, you can check whether your SqlSession is used by multiple threads. – study Aug 11 '22 at 02:19
-
My SqlSession is being shared by multiple threads, and each thread executes different select statements. Could this be a problem caused by Mybatis' cache? I can't be sure of this – study Aug 11 '22 at 02:22