关于数据传输的问题
我从mysql数据库中已经将我所需要的数据提取出来了,现在就是要编写一段代码,把提取出的数据发送出去,然后另一端通过网络把发送的数据接收到,这些操作都不通过页面完成,只是两个程序之间的传输!
请高手帮助解决一下!
谢谢!!
------解决方案--------------------发请求和接收数据代码:
String connectURL = GanttApplet.getURL()
+ "GanttServlet?Req=9&pprc_id= " + GanttApplet.pprc_id
+ "&serialId= " + GanttApplet.serialId;
URL url = new URL(connectURL);
URLConnection urlc = url.openConnection();
urlc.connect();
InputStream inputStream = urlc.getInputStream();
if (inputStream != null) {
Object readObject = null;
ObjectInputStream is = null;
boolean flag = true;
int count = 0;
while (flag && (count < 2)) {
if (inputStream.available() > 0) {
flag = false;
} else {
Thread.sleep(10000);
count++;
}
}
if(!flag){
is = new ObjectInputStream(inputStream);// ストリーム入力
try {
while ((readObject = is.readObject()) != null) {
Vector vecData = (Vector) readObject;
if (vecData != null && vecData.size() > 0) {
propertyValue = (Map) vecData.get(0); // プロパティファイルからの値
String width = (String) vecData.get(1);
if (width != null && !width.equals( " ")) {
hourwidth = Integer.parseInt(width);
}
}
}
} catch (
EOFException e) {
// System.out.println( "getPropertyValue() eof end ");
} catch (Exception e) {
throw e;
} finally {
if (is != null) {
is.close();
}
inputStream.close();
}
}else{
throw new
IOException();
}
}
} catch (IOException e) {
e.printStackTrace();
GanttLogController
.log(GanttErrorMessage.APPLET_ERROR_RECIEVE_MESSAGE + e);
GanttApplet.errorInfo = GanttErrorMessage.APPLET_ERROR_RECIEVE_MESSAGE;
if (win != null) {
try {
win.eval( "window.showMessage(); ");
} catch (Exception ex) {
ex.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
GanttLogController
.log(GanttErrorMessage.APPLET_ERROR_HTTP_CONN_OTHER + e);
GanttApplet.errorInfo = GanttErrorMessage.APPLET_ERROR_HTTP_CONN_OTHER;
if (win != null) {
try {
win.eval( "window.showMessage(); ");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}