title: JDBC Thin Driver: Invalid Packet Lenght [sic]
body: <p>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.  </p>
  
  <p>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.</p>
  
  <p>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).</p>
  
  <p>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 </p>
  
  <pre><code>threadObject.stop();
  </code></pre>
  
  <p>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.</p>
  
  <p>I've tried all of these with the same results:</p>
  
  <ul>
  <li>Reuse the same connection that the
  actual code uses</li>
  <li>Create one new connection an reuse that same second connection for all
  tests</li>
  <li>Close and recreate the test connection every time I stop() a
  long-running test</li>
  <li>Create a new connection for each test (this works until I max out my connection count)</li>
  </ul>
  
  <p>I have determined that of the two connections, "test" and "actual", the "test" connection is the one that throws the exception. </p>
  
  <p>Configuration:</p>
  
  <ul>
  <li>Eclipse 3.4 </li>
  <li>Java Compliance 1.6</li>
  <li>ojdbc14_g.jar JDBC Driver </li>
  <li>Oracle 9 DB </li>
  </ul>
  
  <p>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?</p>