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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:59:39+00:00 2026-05-29T08:59:39+00:00

This is the following code: `package com.tom.jam; //import java.sql.Connection; //import java.sql.DriverManager; import java.sql.*; import

  • 0

This is the following code:

 `package com.tom.jam;

//import java.sql.Connection;
//import java.sql.DriverManager;
 import java.sql.*;
import android.app.Activity;
//import android.database.SQLException;
import android.os.Bundle;
import android.widget.TextView;

 public class MyserverActivity extends Activity {
TextView mf,ct;
  /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mf=(TextView) findViewById(R.id.myfield);
    ct=(TextView) findViewById(R.id.cont);
        Connection con = null;

        try {
          Class.forName("com.mysql.jdbc.Driver");
          con=DriverManager.getConnection("jdbc:mysql://192.168.0.100/test","root", "secret");
          if(!con.isClosed())
          {

              Statement st = con.createStatement();
              ResultSet rs = st.executeQuery("select * from ram");
              while(rs.next())
              {
              ct.setText("ID" + rs.getString(1) + "Name " + rs.getString(2));
              }

            mf.setText("Successfully connected to " +
              "MySQL server using TCP/IP...");

          }
        } catch(Exception e) {
          mf.setText("Exception: " + e.getMessage());
        } finally {
          try {
            if(con != null)
              con.close();
          }catch (java.sql.SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

}
}
}`   

we have set the following permissions in

manifest:android.permission.ACCESS_NETWORK_STATE,
         android.permission.INTERNET,
         android.permission.WRITE_EXTERNAL_STORAGE       

NO errors and warnings but while running emulator is showing the following exception:

 Unable to connect to any hosts due to exception:java.net.SocketTimeoutException:Connection timed out.

Thanks in advance

  • 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-05-29T08:59:40+00:00Added an answer on May 29, 2026 at 8:59 am

    java.net.SocketTimeoutException:Connection timed out, exception occurs when destination system is not reachable. It may be due to proxy not set on your emulator, to set proxy on emulator you can start emulator by command in command prompt:

    emulator -avd avdname -http-proxy http://192.168.1.1:8080
    

    Here replace avdname to name of avd you want to run your program, and http:192.168.1.1 to your proxy server.

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

Sidebar

Related Questions

I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;
The following code works fine on Android 2.1update1 - package com.troubadorian.android.teststreaming; import android.app.Activity; import
I'm running the following code.... package com.dc; import android.app.Activity; import android.content.Intent; import android.net.Uri; import
Top of my code package com.br.openeed.engtoolspro; import android.app.Activity; import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle;
I am using the following code for 2D-QR code decoder. package com.test.rim; import java.util.*;
When I sbt run the following code, package com.example import java.io.ObjectInputStream import java.io.ObjectOutputStream import
I downloaded the selenium-java-2.0a5.zip http://code.google.com/p/selenium/downloads/list and ran the following code: package org.openqa.selenium.example; import org.openqa.selenium.By;
Hi I am using the following code from this site: http://java.sun.com/developer/technicalArticles/ALT/Reflection/ But when I
I use NetBeans 6.5. When I try to run the following code: package com.afrikbrain.numeroteur16;
I'm going by the following code example to dynamically build a preference activity. http://www.linuxtopia.org/online_books/android/devguide/guide/samples/ApiDemos/src/com/example/android/apis/app/PreferencesFromCode.html

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.