NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
kwesiaryee
Joined: 27 Jul 2009 Posts: 4
|
Posted: Mon Jul 27, 2009 12:35 pm Post subject: Need Help Please! Want to pass a input param to entitymanager and query result back to servlet |
|
|
I am trying to use persistence as my data layer. I am developing a login account page with where username and password will be checked before its logged in. I have passed the input strings to the entity manger and return the result to a servlet. but it doesn't seem to work. This is the code | Code: | public Users getMyUsers(String username, String password) {
try {
Context ctx = new InitialContext();
UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/LogicalName");
Query q = em.createQuery("SELECT u FROM Users u WHERE u.username = :username AND u.password = :password");
q.setParameter(username, q);
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", e);
throw new RuntimeException(e);
}
return q;
} |
Please i need help on this ... Thanks |
|
| Back to top |
|
 |
Melongo Annabel Posted via mailing list.
|
Posted: Wed Jul 29, 2009 1:44 am Post subject: Need Help Please! Want to pass a input param to entitymanager and query result back to servlet |
|
|
For someone to help, it would be really helpful to provide a stack trace. Thanks.
From: kwesiaryee <address-removed>
To: address-removed
Sent: Monday, July 27, 2009 7:35:56 AM
Subject: [nbj2ee] Need Help Please! Want to pass a input param to entitymanager and query result back to servlet
I am trying to use persistence as my data layer. I am developing a login account page with where username and password will be checked before its logged in. I have passed the input strings to the entity manger and return the result to a servlet. but it doesn't seem to work. This is the code
Code:
public Users getMyUsers(String username, String password) {
try {
Context ctx = new InitialContext();
UserTransaction utx = (UserTransaction) ctx.lookup("java:comp/env/UserTransaction");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("java:comp/env/persistence/LogicalName");
Query q = em.createQuery("SELECT u FROM Users u WHERE u.username = :username AND u.password = :password");
q.setParameter(username, q);
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", e);
throw new RuntimeException(e);
}
return q;
}
Please i need help on this ... Thanks |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|