以下に示すコーディングを使用して、PHPを使用してサーバーのSQLデータベースからデータを取得できました。データベースを定期的にチェックして、新しいデータが追加されたかどうかを確認する必要があります。追加された場合は、それらを Java アプリケーションに取得する必要があります。私は netbeans IDE を使用して いますが、どうすればこれを行うことができますか?
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();
}
}