java的一个小问题

[复制链接]
查看11 | 回复1 | 2008-12-6 18:35:41 | 显示全部楼层 |阅读模式
public String processLogic() {
Connection c = null;
Statement s = null;
ResultSet r = null;
try {
String dbUrl = "jdbc:hsqldb:hsql://172.31.255.103:9001/frame";
String user = "sa";
String password = "";
Class.forName("org.hsqldb.jdbcDriver");
c = DriverManager.getConnection(dbUrl, user, password);
s = c.createStatement();
r = s.executeQuery("select user_name from ids where user_id='"

+ userid + "' and password='" + password + "' ");
while (r.next()) {
}
System.out.println(userid);
System.out.println(password);
String aaa = r.getString("user_name");
if (aaa == "王湛") {

return SUCCESS;
} else {

return "error";
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {

r.close();

s.close();

c.close();
} catch (SQLException e) {

e.printStackTrace();
}
怎么把if (aaa == "王湛") {

return SUCCESS;
中的return的值返回给processLogic()
高人指点指点啊

回复

使用道具 举报

千问 | 2008-12-6 18:35:41 | 显示全部楼层
SUCCESS 和error 本来就是 函数processLogic() 的返回值啊。当一个对象调用processLogic() 这个函数时返回值就是SUCCESS或error。。。哦,对了,SUCCESS要加引号。 return "success";...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行