哪位大虾能给一段applet通过servlet向数据库获取数据的代码? 万分感谢了!希望能看到结构良好的代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不明白,APPLET可以能通过servlet访问数据库吗? 1.applet在客户端,servlet在服务器端,从客户端大概只能用url的形式访问。2.我建议你把数据服务写成webservice,用applet调用。 URLConnection这个类可以看看。用它访问服务器 import java.net.*;import java.io.*;/**用POST 方式发送数据 然后从结果中读取FileName:SocketURLConnection.java@Author:Alec CheungMSN:[email protected]Home:www.andyfans.comhttp://97741.126.comhttp://cheung.cxc.ccDate:2003-5-23*/public class DoPostURLConnection{ public static void main(String args[]) { try{ URL url = new URL("http://localhost:8888/97741/815/formAction.asp"); URLConnection uc = url.openConnection(); uc.setDoOutput(true); OutputStream raw = uc.getOutputStream(); OutputStream buf = new BufferedOutputStream(raw); OutputStreamWriter out = new OutputStreamWriter(buf,"GBK"); out.write("myName=Alec Cheung&[email protected]"); out.flush(); out.close(); InputStream in = uc.getInputStream(); in = new BufferedInputStream(in); Reader r = new InputStreamReader(in); int c; System.out.println("==================Beging===================="); while((c = r.read()) != -1) System.out.print((char) c); in.close(); System.out.println("===================End======================"); } catch(IOException e){ } }}不是我写的,我对这东西没兴趣,只是随手 GOOGLE 了一下。 我设计了一个BorderLayout的窗口,中间以表格显示数据库数据,老报错 小弟遇到难题了,请教高手!!! 这个程序为什么不会死锁,很郁闷!问谁能解答. 文件编译不过去,什么原因?请看 关于URL的问题?????????? 关于eclipse下创建类 做哪个程序员? 高手~救救我,谁来指点指点我的学习方向啊 mysql+java,insert慢 快帮忙,怎么编译一个大型项目~??? 一个关于数据库取值和线程的问题? 大家帮我看看这个错误是怎么回事
import java.io.*;
/**
用POST 方式发送数据 然后从结果中读取
FileName:SocketURLConnection.java
@Author:Alec Cheung
MSN:[email protected]
Home:www.andyfans.com
http://97741.126.com
http://cheung.cxc.cc
Date:2003-5-23
*/public class DoPostURLConnection
{
public static void main(String args[])
{
try{
URL url = new URL("http://localhost:8888/97741/815/formAction.asp");
URLConnection uc = url.openConnection();
uc.setDoOutput(true); OutputStream raw = uc.getOutputStream();
OutputStream buf = new BufferedOutputStream(raw);
OutputStreamWriter out = new OutputStreamWriter(buf,"GBK");
out.write("myName=Alec Cheung&[email protected]");
out.flush();
out.close(); InputStream in = uc.getInputStream();
in = new BufferedInputStream(in);
Reader r = new InputStreamReader(in);
int c;
System.out.println("==================Beging====================");
while((c = r.read()) != -1)
System.out.print((char) c);
in.close();
System.out.println("===================End======================");
}
catch(IOException e){
}
}
}不是我写的,我对这东西没兴趣,只是随手 GOOGLE 了一下。