Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static SessionFactory sf;
- public void setup() {
- try {
- sf = new AnnotationConfiguration().configure()
- .addPackage("com.registration.domain")
- .addAnnotatedClass
- } catch (Throwable e) {
- System.out.println(e);
- }
- }
- void verifyUser(String usernm,String passwd)
- {
- Session session = sf.openSession();
- Transaction tx = null;
- try{
- tx = session.beginTransaction();
- List<?> lst = session.createQuery("FROM LoginPojo").list();
- for (Iterator<?> iterator =
- lst.iterator(); iterator.hasNext();){
- LoginPojo lpojo = (LoginPojo) iterator.next();
- System.out.print("Username: " + lpojo.getUsernm());
- System.out.print(" Password: " + lpojo.getPasswd());
- if(lpojo.getUsernm().equals(usernm)&& lpojo.getPasswd
- System.out.println("Correct username and password");
- }
- else
- {
- System.out.println("Incorrect username and password");
- }
- }
- tx.commit();
- }catch (HibernateException e) {
- if (tx!=null) tx.rollback();
- e.printStackTrace();
- }finally {
- session.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement