【发布时间】:2015-09-09 14:17:13
【问题描述】:
我在 validator 包中有以下 Java 类 RemoteDBAccess,如下所示。基本上,类中的函数接受一个字符串作为输入,并返回一个字符串 valid 或 invalid 作为输出:
public class RemoteDBAccess {
public String Validator(String input)
{
String Output = "";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
String connectionUrl = "jdbc:mysql://ctovm1873.dev.spotlight.com:3306/ttds";
String connectionUser = "root";
String connectionPassword = "root";
conn = DriverManager.getConnection(connectionUrl, connectionUser, connectionPassword);
stmt = conn.createStatement();
int rowcount = 0;
if(input.startsWith("CHG"))
{
rs = stmt.executeQuery("Select * from rm_projectrepository_gen where snow_change_id like '" + input + "'");
while (rs.next() != false) {
++rowcount;
}
}
else
{
rs = stmt.executeQuery("Select * from rm_projectrepository_gen where idRM_ProjectRepository_Gen like '" + input + "'");
while (rs.next() != false) {
++rowcount;
}
}
if(rowcount == 0)
{
Output = "invalid";
}
else{
Output = "valid";
}
}
catch (Exception e) {
e.printStackTrace();
}
return Output;
}
}
在 remoting-config.xml 文件中,我为 RemoteObject 添加了目的地,如下所示:`
<destination id="RemoteDBAccess">
<properties>
<source>validator.RemoteDBAccess</source>
</properties>
<adapter ref="java-object"/>
</destination>
在我的弹性代码中,我创建了 RemoteObject,如下所示:<mx:RemoteObject id="BeforeWithAfterValidator" destination="RemoteDBAccess" source="validator.RemoteDBAccess" result="Alert.show(event.result.toString());" fault="Alert.show(event.fault.faultString);"/>
现在,当我使用以下代码调用远程方法时:
var Data:String = "1239";
Alert.show(BeforeWithAfterValidator.Validator(Data));
警告框显示:无法创建“validator.RemoteDBAccess”类型的类。
请帮我解决这个问题。
【问题讨论】:
标签: java actionscript-3 apache-flex remoteobject