Advertisement
Guest User

Untitled

a guest
Jan 14th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. Class.forName("org.apache.derby.jdbc.ClientDriver");
  2.  
  3. private static EntityManagerFactory factory;
  4. public static Connection getConnection() {
  5. try {
  6. Class.forName("org.apache.derby.jdbc.ClientDriver");
  7. factory = Persistence.createEntityManagerFactory("Zadanie_3PU");
  8. EntityManager em = factory.createEntityManager();
  9. Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/iab;create=true", "", "");
  10. return con;
  11. }
  12. catch(Exception ex) {
  13. System.out.println("Database.getConnection() Error -->" + ex.getMessage());
  14. return null;
  15. }
  16. }
  17.  
  18. <?xml version="1.0" encoding="UTF-8"?>
  19. <persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  20. <persistence-unit name="Zadanie_3PU" transaction-type="RESOURCE_LOCAL">
  21. <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  22. <class>model.User</class>
  23. <class>model.Email</class>
  24. <exclude-unlisted-classes>false</exclude-unlisted-classes>
  25. <properties>
  26. <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
  27. <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
  28. <property name="javax.persistence.jdbc.url" value="jdbc:derby://localhost:1527/iab;create=true"/>
  29. <property name="javax.persistence.jdbc.user" value=""/>
  30. <property name="javax.persistence.jdbc.password" value=""/>
  31. <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
  32. </properties>
  33. </persistence-unit>
  34. </persistence>
  35.  
  36. Info: Database.getConnection() Error -->Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.DatabaseException
  37. Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/iab;create=true
  38. Error Code: 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement