我用的openamf做flashremoting服务器是没问题的!这是as的代码!package{importflash.display.Sprite;importflash.net.ObjectEncoding;importcom.riafan.remoting.PendingCall;import...
我用的openamf做flash remoting服务器是没问题的!
这是as的代码!
package {
import flash.display.Sprite;
import flash.net.ObjectEncoding;
import com.riafan.remoting.PendingCall;
import com.riafan.remoting.Service;
import com.riafan.rpc.FaultEvent;
import com.riafan.rpc.ResultEvent;
/**
* Flash Remoting ActionScript 3.0
* @author Flying
*/
public class Main extends Sprite {
public function Main() {
//创建远程服务
var service : Service = new Service("tutorials.remoting.insect.src.insect.test.testMysql",
"http://localhost:8080/flashService/gateway",
ObjectEncoding.AMF3);
//调用远程方法
var rpc : PendingCall = service.TestObject();
//注册调用成功的事件侦听器对象
rpc.addEventListener(ResultEvent.RESULT, successHandler);
//注册调用成功失败的侦听器对象
rpc.addEventListener(FaultEvent.FAULT, faultHandler);
}
//声明处理调用成功的侦听器函数
private function successHandler( re : ResultEvent ) : void {
// 您好,Flying。这是来自Fluorine Flash remoting的问候
trace("success");
trace(re.result);
}
//声明处理调用失败的侦听器函数
private function faultHandler( fe : FaultEvent ) : void {
trace(fe.fault.description);
}
}
}
这是java的程序
package tutorials.remoting.insect.src.insect.test;
import java.sql.*;
import java.util.*;
public class testMysql {
public static void main(String[] args){
TestObject();
System.out.println(TestObject());
}
public static List TestObject() {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
List list = new ArrayList();
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection
("jdbc:mysql://localhost/insectdata?user=root&password=insect");
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from level where id = 1");
while (rs.next()) {
Map data = new HashMap();
data.put("等级", rs.getInt("crtlevel"));
data.put("金钱", rs.getString("money"));
data.put("经验", rs.getInt("experience"));
list.add(data);
}
//System.out.println(list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
}
帮忙看看哪里有什么问题?
展开