Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 174481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:31:48+00:00 2026-05-11T13:31:48+00:00

I have encountered a strange Invalid Packet Lenght (that is how the error is

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:31:48+00:00Added an answer on May 11, 2026 at 1:31 pm

    I don’t really understand what are you trying to accomplish with your bulk test, so I will offer some general advice regarding threading and Connections that I know of:

    1. Perhaps one of your threads is leaving a connection in invalid state. What happens to connection when thread is stopped? In general terms, you should have a place where you wait() for an InterruptedException instead of stopping the thread in mid-operation. A Connection should be closed in a finally block, regardless of whether an exception occurred or not.

    2. If you want a timeout for a JDBC operation, use Statement.setQueryTimeout().

    3. Consider using a connection pool, like C3P0. It’s really easy to set up in code, have a look at this in particular. It will take care of most of the connection set-up/tear-down and provide your code with valid, ready-to-use connection.

    4. Consider using Java’s own java.util.concurrent package, rather than rolling out your own execution strategy. Have a look at Executors and ExecutorService classes – they provide means of executing a task in separate thread, and setting up a timeout.

    Hope some of this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

I have encountered a strange behavior while executing an sql query on the Oracle
I have encountered a strange behavior with a simple C++ class. classA.h class A
I'm having a strange problem and not sure how to troubleshoot it. I have
This is a strange one... In a windows forms app (VB.NET/VS 2005) I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.