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;
}