English 中文(简体)
如何向服务器发送大量文本?
原标题:Better way to send lots of text to a server?
  • 时间:2011-03-22 21:03:46
  •  标签:
  • java
  • php
  • sql

我有一刀切的申请,将案文发送到服务器的 s数据库。 目前,我的java申请采用了该文本,将其放入了圆顶,然后将其发送到服务器上一个带有GET的站点,并将其输入数据库。 问题在于,需要能够发送大量的文本,而且要保留414条,留有很长的错误。 是否有更好的办法这样做?

ok,我对你所说的话进行了审判,阅读了理论,但有些事情没有奏效。 我的法典就是在这里尝试的。

public  void submitText(String urls,String data) throws IOException{
    URL url = new URL(urls);
    URLConnection con = url.openConnection();
    con.setRequestProperty("Content-Type", "text/plain; charset=utf-8");

    con.setDoOutput(true);

    OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(), "UTF-8");
    out.write(data);
    out.flush();


}
submitText(server + "publicPB.php", "param=" +  text);

这里是我的《加拿大刑法》。

$param = $_POST[ param ];
$sql = "UPDATE table SET cell= {$param}  WHERE 1";
mysql_query($sql);
...

确实,它并不与设在加拿大的营地存在问题,因为营地与GET公司合作得当,而且随着这一变化,我认为问题不是100%确保如何用java向它发送数据。

最佳回答

使用<代码>POST而不是GET,并将案文作为申请机构发送。 你们只能把如此多的数据传递给欧洲增长论坛。 例如:

// Assuming  input  is a String and contains your text
URL url = new URL("http://hostname/path");
URLConnection con = url.openConnection();
con.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
con.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(), "UTF-8");
out.write(input);
out.close();

See 。 阅读和书写更多细节。

问题回答

采用无内容长度限制的POST申请。

POST的请求内容没有时限,而且比GET的要求安全得多。

如果使用服务器,我将研究如何利用BCP。 你可以在 Java内撰写档案和打电话给BCP,并将直接向您的数据库发送信息。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签