我使用flex 通过RemoteObject与java交互,java访问SQL Server2005,但是总是返回NaN。
单独使用java可以访问数据库。而且返回值也正确。实在不知道是什么问题?publicUserBeanGetUserInfo(Stringname,Stringpasswo...
单独使用java可以访问数据库。而且返回值也正确。实在不知道是什么问题?
public UserBean GetUserInfo(String name, String password){
String user;
String code;
String result = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:hsxqwfxc";
Connection con= DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("select * from dengLu");
while (rs.next()) {
user = rs.getString(1);
code = rs.getString(2);
if (user.equals(name)&&code.equals(password)){
result="OK";
break;
} else {
result="NotFound";
}
}
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
result = "NaN";
}
return new UserBean(result);
} 展开
public UserBean GetUserInfo(String name, String password){
String user;
String code;
String result = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:hsxqwfxc";
Connection con= DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement();
ResultSet rs = stmt.executeQuery("select * from dengLu");
while (rs.next()) {
user = rs.getString(1);
code = rs.getString(2);
if (user.equals(name)&&code.equals(password)){
result="OK";
break;
} else {
result="NotFound";
}
}
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
result = "NaN";
}
return new UserBean(result);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询