public String loginUser(String username, String password) throws EJBException { String userId = null;
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
try
{
connection = dataSource.getConnection();
String sql = "select userid from webstockaccess where username = ? and password = ?";
ps = connection.prepareStatement(sql);
ps.setString(1, username);
ps.setString(2, password);
rs = ps.executeQuery();
while (rs.next())
userId = rs.getString(1);
rs.close();
ps.close();
connection.close(); } catch (SQLException e)
{
// do nothing, we will return null
e.printStackTrace();
}
return userId;
}
Connection connection = null;
PreparedStatement ps = null;
ResultSet rs = null;
try
{
connection = dataSource.getConnection();
String sql = "select userid from webstockaccess where username = ? and password = ?";
ps = connection.prepareStatement(sql);
ps.setString(1, username);
ps.setString(2, password);
rs = ps.executeQuery();
while (rs.next())
userId = rs.getString(1);
rs.close();
ps.close();
connection.close(); } catch (SQLException e)
{
// do nothing, we will return null
e.printStackTrace();
}
return userId;
}
解决方案 »
- java 后台认证网页的用户名和密码登录网页???
- 操作权限问题ssh框架
- jni 可以调C++的应用程序服务器中的函数吗?
- 用hibernate的反向工程建立了实体类之后。如果数据库改变,那么如何更新,而不是重新生成
- XML的解释技术有哪些,什么是解释技术哦?
- j2ee系统如何简单实现"服务器版转单机版"
- 用Digester 解析xml,我晕了,大侠们来帮个忙!!
- ssh中怎么用LookupDispatchAction
- 哪位大哥做华为MMS网关的收发程序,能不能共享一下阿!谢谢
- 高手帮忙!tomcat问题,有效立即给分结贴!在线等
- 动态的java问题(hibernate,javabean,mvc括号的东西是为了便于大家搜索到我~)
- 用<html:link>如何传递参数呢?
rs.close();
这里是不是应该先关rs啊?