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

  • Home
  • SEARCH
  • 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 8678497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:44:12+00:00 2026-06-12T20:44:12+00:00

I am trying to put an entry in database. This is the code I

  • 0

I am trying to put an entry in database. This is the code I am using

String url = String.format("http://xxxxxxx/xxx/index.php?home=yes&pid=%s", pid);

        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost(url);

    try {
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String response = httpclient.execute(httppost, responseHandler);

        Log.e("abc", response);
        return response;
        } catch (ClientProtocolException es) 
        {   
            Log.e("x" , es.getMessage());
            return "";
        } catch (IOException e) 
        {
            Log.e("aasx" , e.getMessage());
            return "";
        }

This code works fine. Now when there is an internet connection problem, the code stuck at
httpclient.execute(httppost, responseHandler); for more than 2 minutes.

Is there any way in which it check for only few seconds and if no resposne then catch the exceptions?

  • 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-12T20:44:14+00:00Added an answer on June 12, 2026 at 8:44 pm

    Your question is similar to the one here.

    You just need to set a timeout for the HttpClient as shown in the answers there. This can be done by passing in an HttpParams object to the HttpClient constructor.

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

Sidebar

Related Questions

I have been trying to test this out. I put in the code below
Trying to put a regex expression together that returns the string between _ and
I'm trying to put together a layout using Bootstrap that resembles your typical OS
I have a table in my ms sql database and am using PHP. What
I am using php to pull information out of a database, but I have
I'm trying to post to Blogger using idHTTP component, however, I'm getting HTTP/1.0 400
I'm trying to put into form ( select ) some values from database: val
I'm trying put an if statement directly into a select field in rails, with
I trying to put together an Android app that will take a picture and
I'm trying to put together a script to monitor the MSMQ on a server.

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.