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 8823623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:24:14+00:00 2026-06-14T06:24:14+00:00

I have the following scenario in a Java program: … try // 1 PreparedStatement

  • 0

I have the following scenario in a Java program:

...
try

   // 1
   PreparedStatement pstmt1 = conn.getPreparedStatement("SQL QUERY");
   pstmt1.setQueryTimeout(1);
   pstm.executeUpdate();
   System.out.println("1 executed");

   // 2
   PreparedStatement pstmt2 = conn.getPreparedStatement("SQL QUERY");
   pstmt2.setQueryTimeout(1);
   pstmt2.executeUpdate();
   System.out.println("2 executed");

   // 3
   PreparedStatement pstmt3 = conn.getPreparedStatement("SQL QUERY");
   pstmt3.setQueryTimeout(1);
   pstmt3.executeUpdate();
   System.out.println("3 executed");

catch(Exception e){

     e.printStackTrace();

}
...

If I “unplug the cable” and the connection to the database is lost just after the first executeUpdate() call. How can I tell the program to wait only for 1 second and if no response go into the catch immediately?

Now what is happening is that the program get stuck after that point (the first executeUpdate(), at the output “1 executed”).

The method pstmt.setQueryTimeout(1) seems to be not working.

I’ve set the connection timeout in 10 seconds on the connection pools properties of the server.

After a lot of minutes (half an hour) I get the following error (the expected error):

The Connection Manager received a fatal connection error from the Resource Adapter for resource jdbc/JNDI_BD1.  The exception which was received is com.ibm.websphere.ce.cm.StaleConnectionException: [jcc][t4][2030][11211][3.58.82] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream.  Error location: Reply.fill().  Message: No route to host. ERRORCODE=-4499, SQLSTATE=08001:com.ibm.db2.jcc.am.io: [jcc][t4][2030][11211][3.58.82] A communication error occurred during operations on the connection's underlying socket, socket input stream, or socket output stream.  Error location: Reply.fill().  Message: No route to host. ERRORCODE=-4499, SQLSTATE=08001:java.net.SocketException: No route to host

Any help is very appreciated.

  • 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. Editorial Team
    Editorial Team
    2026-06-14T06:24:15+00:00Added an answer on June 14, 2026 at 6:24 am

    Not all drivers support query timeouts. But even if they did: the query timeout is not intended to detect network timeouts. Most likely options like query timeouts will be handled by the database server (ie: the driver asking the server: abort the query if it takes longer than xxx), or the driver and/or server don’t support it at all.

    The socket timeout is a much lower level timeout, and most drivers will have a connection property setting for this (so_timeout, socket timeout etc).

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

Sidebar

Related Questions

I have question about try, catch and finally in Java. Consider the following scenario:
I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario (in Java / Hibernate): I have two entity classes:
We have following scenario: We have a chain of map-reduce processes implemented in java.Currently
I have the following scenario of integrating a third party application into my java
I have the following scenario: 1. I creat a JFrame jFrame in a FrontEnd.java
I am rather noob at java jars deployment. I have following scenario: I have
Image the following scenario, You have 10 Java applications accessing a database server Each
On bash, I have the following (typical) scenario: ~/some/dir$ find | grep java which
I have the following scenario: in activity A, when a user clicks a button,

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.