I have encountered a strange "Invalid Packet Lenght" (that is how the error is spelled) error when I run an automated bulk test on some of my Java code and I hope that someone has either encountered this error before or can point me in the right direction.
I do not encounter this error when testing my code via JUnit unit tests or from the GUI. I only encounter this error on my automated bulk test. A little bit about my bulk test: for some inputs my code will run for a long time (that's to be expected), but in order to speed up the results to a more reasonable time frame I'm creating a new thread to run each individual test so that I can stop the test after some given maximum elapsed time.
Note that both the test and the actual code need to connect to the same database instance to load data. The actual code uses a single connection to read from the database (it is not multi-threaded). I'm still trying to figure out the best way for the test to connect to the database (hence this question).
My first thought was that I am doing something unfriendly in the way I close my test thread to quit the run early. I'm calling the deprecated
threadObject.stop();
method since my actual code is not multi-threaded an there is no "friendly" way to kill the thread built in. After a few (~2-3) stopped threads, my JDBC connection throws one "Invalid Packet Lenght" error followed by "Socket closed" exceptions for the rest of the tests.
I've tried all of these with the same results:
- Reuse the same connection that the actual code uses
- Create one new connection an reuse that same second connection for all tests
- Close and recreate the test connection every time I stop() a long-running test
- Create a new connection for each test (this works until I max out my connection count)
I have determined that of the two connections, "test" and "actual", the "test" connection is the one that throws the exception.
Configuration:
- Eclipse 3.4
- Java Compliance 1.6
- ojdbc14_g.jar JDBC Driver
- Oracle 9 DB
What am I doing wrong? Is there a different way I should handle my "test" connection? Do I need to re-architect my "actual" connection just to run a bulk test? What causes the "Invalid Packet Lenght" error?