Advertisement
Guest User

Untitled

a guest
Jun 6th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  3. <hibernate-configuration>
  4. <session-factory>
  5. <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  6. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  7. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/mydb</property>
  8. <property name="hibernate.connection.username">xxxx</property>
  9. <property name="hibernate.connection.password"><![CDATA[xxxx]]></property>
  10. <property name="hibernate.current_session_context_class">thread</property>
  11. <property name="hibernate.show_sql">false</property>
  12. <property name="hibernate.c3p0.min_size">10</property>
  13. <property name="hibernate.c3p0.max_size">100</property>
  14. <property name="hibernate.c3p0.timeout">300</property>
  15. <property name="hibernate.c3p0.max_statements">100</property>
  16. <property name="hibernate.c3p0.idle_test_period">500</property>
  17. <!-- Enable Hibernate's automatic session context management -->
  18. <property name="current_session_context_class">thread</property>
  19. <!-- Disable the second-level cache -->
  20. <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
  21. <!-- Echo all executed SQL to stdout -->
  22. <property name="show_sql">false</property>
  23. <!-- Drop and re-create the database schema on startup -->
  24. <property name="hbm2ddl.auto">validate</property>
  25. </session-factory>
  26. </hibernate-configuration>
  27.  
  28. public String verificaLogin() throws ClassNotFoundException, SQLException, IOException {
  29. CrudUtenti crud = new CrudUtenti();
  30. ArrayList<Utenti> arrayUt = crud.SelectUtenteByMailPasswordAndAbilitato(getEmail(), password);
  31. if (arrayUt.size() != 1) {
  32. cssLogin="loginSbagliata";
  33. return out;
  34. }
  35. out = "success";
  36. //cut
  37. return out;
  38. }
  39.  
  40. public CrudUtenti(){
  41. if(WgHibernateUtil.getSessionFactory().getCurrentSession() instanceof Session){
  42. setMainSession(WgHibernateUtil.getSessionFactory().getCurrentSession());
  43. }else{
  44. setMainSession(WgHibernateUtil.getSessionFactory().openSession());
  45. }
  46.  
  47. }
  48.  
  49. public ArrayList<Utenti> SelectUtenteByMailPasswordAndAbilitato(String email,String password){
  50. Transaction t;
  51. t = mainSession.beginTransaction();
  52. ArrayList<Utenti> u =(ArrayList<Utenti>) mainSession.createQuery("from Utenti u where u.em ='"+email+"' and u.pa='"+ password+ "' and abilitato = 100" ).list();
  53.  
  54. if(t.isActive()){
  55. t.commit();
  56. }
  57. return u;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement