Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. <property name="connection.provider_class">org.jasypt.hibernate4.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider</property>
  2.  
  3. <property name="connection.encryptor_registered_name">configurationHibernateEncryptor</property>
  4. <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
  5. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  6. <property name="connection.url">jdbc:mysql://localhost:3306/aprendiendojsf?autoReconnect=true</property>
  7. <property name="connection.username">root</property>
  8. <property name="connection.password">ENC(lhFCMXdRkAw7Cz5JU17lvg==)</property>
  9. <property name="show_sql">true</property>
  10. <property name="current_session_context_class">thread</property>
  11.  
  12. public class HibernateUtil {
  13.  
  14. private static SessionFactory sessionFactory = null;
  15.  
  16. static {
  17. try {
  18. // Create the SessionFactory from standard (hibernate.cfg.xml)
  19. // config file.
  20. sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
  21.  
  22. StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
  23. encryptor.setAlgorithm("PBEWithMD5AndDES");
  24. encryptor.setPassword("clave");
  25. HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
  26. registry.registerPBEStringEncryptor("configurationHibernateEncryptor", encryptor);
  27. } catch (Throwable ex) {
  28. // Log the exception.
  29. System.err.println("Initial SessionFactory creation failed." + ex);
  30. ex.printStackTrace();
  31. }
  32. }
  33.  
  34. public static SessionFactory getSessionFactory() {
  35. return sessionFactory;
  36. }
  37.  
  38. INFO: HHH000046: Connection properties: {user=root, encryptor_registered_name=configurationHibernateEncryptor, password=****}
  39.  
  40. WARN: HHH000342: Could not obtain connection to query metadata : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
  41.  
  42. public class HibernateUtil {
  43.  
  44. private static SessionFactory sessionFactory = null;
  45.  
  46.  
  47. static {
  48. try {
  49.  
  50.  
  51.  
  52. EnvironmentStringPBEConfig envConfig = new EnvironmentStringPBEConfig();
  53. envConfig.setPasswordEnvName(“DB_SIMETRIC_KEY”);
  54.  
  55. sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
  56.  
  57. StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
  58. encryptor.setAlgorithm("PBEWithMD5AndDES");
  59. encryptor.setConfig(envConfig);
  60.  
  61. HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
  62. registry.registerPBEStringEncryptor("configurationHibernateEncryptor", encryptor);
  63. } catch (Throwable ex) {
  64. // Log the exception.
  65. System.err.println("Initial SessionFactory creation failed." + ex);
  66. ex.printStackTrace();
  67. }
  68.  
  69.  
  70. }
  71. public static SessionFactory getSessionFactory() {
  72. return sessionFactory;
  73.  
  74.  
  75. }
  76. }
  77.  
  78. WARN: HHH000342: Could not obtain connection to query metadata : Could not create connection to database server. Attempted reconnect 3 times. Giving up.
  79.  
  80. public class HibernateUtil {
  81.  
  82. private static SessionFactory sessionFactory = null;
  83.  
  84. static {
  85. try {
  86.  
  87. EnvironmentStringPBEConfig envConfig = new EnvironmentStringPBEConfig();
  88. envConfig.setPasswordEnvName(“DB_SIMETRIC_KEY”);
  89.  
  90. sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
  91.  
  92. StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
  93. encryptor.setAlgorithm("PBEWithMD5AndDES");
  94. encryptor.setConfig(envConfig);
  95.  
  96. HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
  97. registry.registerPBEStringEncryptor("configurationHibernateEncryptor", encryptor);
  98. } catch (Throwable ex) {
  99. // Log the exception.
  100. System.err.println("Initial SessionFactory creation failed." + ex);
  101. ex.printStackTrace();
  102. }
  103. }
  104.  
  105. public static SessionFactory getSessionFactory() {
  106. return sessionFactory;
  107. }
  108.  
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement