Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. HibernateFactory.buildSessionFactory();
  2. primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
  3. @Override
  4. public void handle(WindowEvent event) {
  5.  
  6. HibernateFactory.closeFactory();
  7. }
  8. });`
  9.  
  10. <?xml version="1.0" encoding="UTF-8"?>
  11. <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
  12. <hibernate-configuration>
  13. <session-factory>
  14. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  15. <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
  16. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ClinicaVet?UseTimezone=true&serverTimezone=UTC</property>
  17. <property name="hibernate.connection.username">root</property>
  18. <property name="hibernate.connection.password">jailbreak</property>
  19. <property name="current_session_context_class">thread</property>
  20. <!-- Disable the second level cache -->
  21. <property
  22.  
  23. name="cache.provider_class">org.hibernate.cache.internall.NoCacheProvider</property>
  24. <!-- Echo all executed SQL to stdout -->
  25. <property name="show_sql">true</property>
  26. <!-- Drop and re-create the database schema on startup -->
  27. <property name="hbm2dd1">update</property>
  28. <mapping resource="com/arthurpdj/entity/Agendamento.hbm.xml"/>
  29. <mapping resource="com/arthurpdj/entity/Animal.hbm.xml"/>
  30. <mapping resource="com/arthurpdj/entity/Cliente.hbm.xml"/>
  31. <mapping resource="com/arthurpdj/entity/Examinacao.hbm.xml"/>
  32. <mapping resource="com/arthurpdj/entity/Exame.hbm.xml"/>
  33. <mapping resource="com/arthurpdj/entity/Vacinacao.hbm.xml"/>
  34. <mapping resource="com/arthurpdj/entity/Notificacoes.hbm.xml"/>
  35. <mapping resource="com/arthurpdj/entity/Vacina.hbm.xml"/>
  36. <mapping resource="com/arthurpdj/entity/Atendimento.hbm.xml"/>
  37. <mapping resource="com/arthurpdj/entity/Pagamento.hbm.xml"/>
  38. </session-factory> </hibernate-configuration>
  39.  
  40. public class HibernateUtil {
  41.  
  42. private static SessionFactory factory = null;
  43. private static Configuration conf;
  44. private static ServiceRegistry serviceRegistry;
  45.  
  46. private static SessionFactory buildSessionFactory() {
  47. try{
  48. conf = new Configuration();
  49. conf.configure("com/arthurpdj/database/hibernate.cfg.xml");
  50. serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
  51. conf.getProperties()).build();
  52.  
  53. System.out.println("Configurou");
  54.  
  55. factory = conf.buildSessionFactory(serviceRegistry);
  56. System.out.println("construi");
  57.  
  58. return factory;
  59. } catch(Throwable ex) {
  60. ex.printStackTrace();
  61. throw new ExceptionInInitializerError(ex);
  62. }
  63.  
  64. }
  65.  
  66. public static SessionFactory getSessionFactory(){
  67. if(factory ==null) {
  68. factory = buildSessionFactory();
  69.  
  70.  
  71. }
  72. return factory;
  73. }
  74.  
  75. }
  76.  
  77. fev 02, 2017 3:05:14 PM org.hibernate.Version logVersion
  78. INFO: HHH000412: Hibernate Core {5.2.7.Final}
  79. fev 02, 2017 3:05:14 PM org.hibernate.cfg.Environment <clinit>
  80. INFO: HHH000206: hibernate.properties not found
  81. fev 02, 2017 3:05:14 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
  82. INFO: HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  83. fev 02, 2017 3:05:15 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
  84. WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  85. Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
  86. fev 02, 2017 3:05:15 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  87. INFO: HHH10001005: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/ClinicaVet?UseTimezone=true&serverTimezone=UTC]
  88. fev 02, 2017 3:05:15 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  89. INFO: HHH10001001: Connection properties: {user=root, password=****}
  90. fev 02, 2017 3:05:15 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
  91. INFO: HHH10001003: Autocommit mode: false
  92. fev 02, 2017 3:05:15 PM org.hibernate.engine.jdbc.connections.internal.PooledConnections <init>
  93. INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
  94. Thu Feb 02 15:05:16 BRST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
  95. fev 02, 2017 3:05:16 PM org.hibernate.dialect.Dialect <init>
  96. INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
  97.  
  98. @Override
  99. public void start(Stage primaryStage) {
  100.  
  101. try {
  102. Parent root = FXMLLoader.load(getClass().getResource("view/FXMLLogin.fxml"));
  103. Scene scene = new Scene(root, 424, 331);
  104.  
  105. primaryStage.setMaximized(false);
  106. primaryStage.setResizable(false);
  107. primaryStage.setTitle("Clinica VeterinĂ¡ria BarraVet");
  108. primaryStage.setScene(scene);
  109. primaryStage.show();
  110.  
  111. HibernateFactory.buildSessionFactory();
  112. primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
  113. @Override
  114. public void handle(WindowEvent event) {
  115.  
  116.  
  117. HibernateFactory.closeFactory();
  118. }
  119. });
  120.  
  121.  
  122. } catch (Exception e) {
  123. e.printStackTrace();
  124. }
  125. }
  126.  
  127. /**
  128. * @param args the command line arguments
  129. */
  130. public static void main(String[] args) {
  131. launch(args);
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement