Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. final Map<String, String> properties = new HashMap<String, String>();
  2. properties.put("javax.persistence.jdbc.user", LoginInfo.getLoginInfo().getUsername());
  3. properties.put("javax.persistence.jdbc.password", LoginInfo.getLoginInfo().getPassword());
  4. properties.put("javax.persistence.jdbc.url", "jdbc:oracle:thin:@localhost:3306:TestHibernate");
  5. // or
  6. properties.put("javax.persistence.jdbc.url", "jdbc:mysql://localhost:3306/TestHibernate");
  7. try {
  8. Persistence.createEntityManagerFactory("PeopleEntity", properties);
  9. } catch (final PersistenceException error) {
  10. Logger.error(getClass(), error.getMessage());
  11. }
  12.  
  13. <persistence
  14. xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  15. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  16. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
  17. http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  18. version="2.1">
  19.  
  20. <persistence-unit
  21. name="PeopleEntity"
  22. transaction-type="RESOURCE_LOCAL">
  23. <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
  24. <class>com.billsdesk.util.hibernate.tests.PeopleEntity</class>
  25. <properties>
  26. <property
  27. name="hibernate.connection.driver_class"
  28. value="com.mysql.jdbc.Driver"></property>
  29. <property
  30. name="javax.persistence.jdbc.driver"
  31. value="oracle.jdbc.OracleDriver"></property>
  32. <property
  33. name="hibernate.dialect"
  34. value="org.hibernate.dialect.MySQL5Dialect" />
  35.  
  36. <!-- URL, user, and password are passed as properties -->
  37.  
  38. </properties>
  39. </persistence-unit>
  40. </persistence>
  41.  
  42. <dependencies>
  43.  
  44. <!-- Hibernate -->
  45.  
  46. <dependency>
  47. <groupId>com.oracle.jdbc</groupId>
  48. <artifactId>ojdbc8</artifactId>
  49. <version>12.2.0.1</version>
  50. </dependency>
  51.  
  52. <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  53. <dependency>
  54. <groupId>mysql</groupId>
  55. <artifactId>mysql-connector-java</artifactId>
  56. <version>6.0.6</version>
  57. </dependency>
  58.  
  59. <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
  60. <dependency>
  61. <groupId>org.hibernate</groupId>
  62. <artifactId>hibernate-core</artifactId>
  63. <version>5.2.10.Final</version>
  64. </dependency>
  65.  
  66. <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
  67. <dependency>
  68. <groupId>org.hibernate</groupId>
  69. <artifactId>hibernate-entitymanager</artifactId>
  70. <version>5.2.10.Final</version>
  71. </dependency>
  72.  
  73. <!-- https://mvnrepository.com/artifact/javax.persistence/persistence-api -->
  74. <dependency>
  75. <groupId>javax.persistence</groupId>
  76. <artifactId>persistence-api</artifactId>
  77. <version>1.0.2</version>
  78. </dependency>
  79.  
  80. <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
  81. <dependency>
  82. <groupId>org.apache.logging.log4j</groupId>
  83. <artifactId>log4j-core</artifactId>
  84. <version>2.8.2</version>
  85. </dependency>
  86. </dependencies>
  87.  
  88. 14:00:45.861 [main] INFO org.hibernate.Version - HHH000412: Hibernate Core {5.2.10.Final}
  89. 14:00:45.862 [main] INFO org.hibernate.cfg.Environment - HHH000206: hibernate.properties not found
  90. 14:00:45.910 [main] INFO org.hibernate.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
  91. 14:00:46.088 [main] WARN org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
  92. 14:00:46.127 [main] INFO org.hibernate.orm.connections.pooling - HHH10001005: using driver [oracle.jdbc.OracleDriver] at URL [jdbc:oracle:thin:@localhost:3306:TestHibernate]
  93. 14:00:46.127 [main] INFO org.hibernate.orm.connections.pooling - HHH10001001: Connection properties: {user=sa, password=****}
  94. 14:00:46.128 [main] INFO org.hibernate.orm.connections.pooling - HHH10001003: Autocommit mode: false
  95. 14:00:46.130 [main] INFO org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl - HHH000115: Hibernate connection pool size: 20 (min=1)
  96. 2017-07-06 14:00:46 SEVERE Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement