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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:12:46+00:00 2026-06-11T12:12:46+00:00

using the coding shown below i have managed to retrive data from a sql

  • 0

using the coding shown below i have managed to retrive data from a sql database in a server using php.
i need to check database periodically to see if any new data added and if any, i need to retrive them to my java application.
i’m using netbeans IDE
how can i do this?

try {
    URL url = new URL("http://taxi.com/login.php?param=10");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    conn.setRequestProperty("Accept", "application/json");

    if (conn.getResponseCode() != 200) {
        throw new RuntimeException("Failed : HTTP error code : "
                + conn.getResponseCode());
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(
        (conn.getInputStream())));

    String output;
    System.out.println("Output from Server .... \n");
    while ((output = br.readLine()) != null) {
        System.out.println(output);
    }

    conn.disconnect();

  } catch (MalformedURLException e) {

    e.printStackTrace();

  } catch (IOException e) {

    e.printStackTrace();

  }

}
  • 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-11T12:12:47+00:00Added an answer on June 11, 2026 at 12:12 pm

    In this solution, I assume that you use at least Java 5.
    Let’s say you want to check for new data every 5 minutes and terminate after 25 minutes.
    You would do this :

    PHPDataChecker.java

    public class PHPDataChecker implements Runnable {
        public void run() {
           // Paste here all the code in your question
        }
    }
    

    Main.java

    public class Main {
        private static boolean canStop=false;
    
        private static void stopPHPDataChecker() {
            canStop=true;
        }
    
        public static void main(String[] args) {
            // Setup a task for checking data and then schedule it
            PHPDataChecker pdc = new PHPDataChecker();
            ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
            final ScheduledFuture<?> pdcHandle = scheduler.scheduleAtFixedRate(pdc, 0L, 5L, TimeUnit.MINUTES);// Start pooling
    
            // Setup a new task to kill the polling after 25 minutes
            scheduler.schedule(new Runnable() {
    
                public void run() {
                    System.out.println(">> TRY TO STOP!!!");
                    pdcHandle.cancel(true);
                    Main.stopPHPDataChecker();
                    System.out.println("DONE");
                }
    
            }, 25L, TimeUnit.MINUTES);
    
            // Actively wait stop condition (canStop)
            do {
                if (canStop) {
                    scheduler.shutdown();
                }
            } while (!canStop);
    
            System.out.println("END");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web based program which chooses some records from a database using
Previously i have used restful wcf webservices to get the data from server.But now
I'm coding in VS2008 using C#. On my form, I have a ListView control.
I'm coding a windows form using WPF, XAML, C#. I have a Frame object
I have couple of forms on my php page. I am using jQuery (&
One can accomplish same thing using different tools. So have I in examples below.
Hi people I have the following code (shown below) and I am trying to
I am using strcmp as shown below. I am debugging the values and which
I have developed a screen in swings to download a file from the server.
I have a WTP project in eclipse that is using Tomcat7 as server, everything

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.