这正是问题所在。 我试图利用MySQL JConnector为 Java,而人们却说不了,因为它可以包含你的详细内容,因此我告诉他们,我使用PHP文字使用PHP_GET方法URLs。 他们说,这将是罚款。 然而,我发现两个问题。
1) 速度缓慢。 至少需要4至5秒才能完成。 即便是当我向当地东道方说的话。
b) 它有许多法典。 Maybe 我只是错了吗?
在这里,我做了哪些工作!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;
import java.awt.TextArea.*;
import java.util.*;
import java.net.*;
import java.applet.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class test extends JApplet
{
public JTextArea c;
public void init()
{
c = new JTextArea();
add(c);
c.append("Let s change the level!");
try
{
URL game = new URL("http://localhost/mystikrpg/game.php?act=stats&username=Dan");
URLConnection connection = game.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
String command = inputLine;
System.out.println(command);
String[] temp = command.split("\|");
c.append("
You re Lvl is: " + temp[1]);
}
in.close();
c.append("
Trying to update level...");
String newLevel = "777";
URL newGame = new URL("http://localhost/mystikrpg/game.php?act=updateLvl&username=Dan&lvl=" + newLevel);
URLConnection levelConnection = newGame.openConnection();
BufferedReader level_BR = new BufferedReader(new InputStreamReader(levelConnection.getInputStream()));
URL updateLevelURL = new URL("http://localhost/mystikrpg/game.php?act=stats&username=Dan");
URLConnection up_lvl_conn = updateLevelURL.openConnection();
BufferedReader up_lvl_br = new BufferedReader(new InputStreamReader(up_lvl_conn.getInputStream()));
String getLvl;
while ((getLvl = up_lvl_br.readLine()) != null)
{
String[] newLvl = getLvl.split("\|");
c.append("
You re NEW Lvl is: " + newLvl[1]);
// newLvl[1] == newLevel
}
c.append("
Level update done!");
level_BR.close();
up_lvl_br.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
这里的答复是:
Let s change the level!
You re Lvl is: 123456
Trying to update level...
You re NEW Lvl is: 777
Level update done!
它虽然运作缓慢而且多半——我如何解决这个问题?