[debutant] Class [org.apache.derby.jdbc.ClientDriver] not found.
a chaque fois que je lance l'application j'ai cette erreur :cry:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| run:
[TopLink Info]: 2009.01.07 11:42:13.921--ServerSession(12115695)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
Exception in thread "main" Local Exception Stack:
Exception [TOPLINK-4003] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Exception Description: Configuration error. Class [org.apache.derby.jdbc.ClientDriver] not found.
at oracle.toplink.essentials.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:101)
at oracle.toplink.essentials.sessions.DefaultConnector.loadDriver(DefaultConnector.java:183)
at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:98)
at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)
at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:120)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:91)
at gestionpersonne.PersonneJpaController.getEntityManager(PersonneJpaController.java:28)
at gestionpersonne.PersonneJpaController.create(PersonneJpaController.java:34)
at gestionpersonne.Main.main(Main.java:20)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds) |
persistence.xml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="gestionPersonnePU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>gestionpersonne.Personne</class>
<properties>
<property name="toplink.jdbc.user" value="linuxien"/>
<property name="toplink.jdbc.password" value="2020"/>
<property name="toplink.jdbc.url" value="jdbc:derby://localhost:1527/GPersonne_db"/>
<property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.ClientDriver"/>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
package gestionpersonne;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
*
* @author linuxien
*/
@Entity
public class Personne implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String nom;
public Personne() {
}
public Personne(String nom) {
this.nom = nom;
}
/**
* Get the value of nom
*
* @return the value of nom
*/
public String getNom() {
return nom;
}
/**
* Set the value of nom
*
* @param nom new value of nom
*/
public void setNom(String nom) {
this.nom = nom;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Personne)) {
return false;
}
Personne other = (Personne) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "gestionpersonne.Personne[id=" + id + "]";
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
package gestionpersonne;
import gestionpersonne.exceptions.NonexistentEntityException;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
/**
*
* @author linxien
*/
public class PersonneJpaController {
public PersonneJpaController() {
emf = Persistence.createEntityManagerFactory("gestionPersonnePU");
}
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(Personne personne) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(personne);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(Personne personne) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
personne = em.merge(personne);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = personne.getId();
if (findPersonne(id) == null) {
throw new NonexistentEntityException("The personne with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Personne personne;
try {
personne = em.getReference(Personne.class, id);
personne.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The personne with id " + id + " no longer exists.", enfe);
}
em.remove(personne);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<Personne> findPersonneEntities() {
return findPersonneEntities(true, -1, -1);
}
public List<Personne> findPersonneEntities(int maxResults, int firstResult) {
return findPersonneEntities(false, maxResults, firstResult);
}
private List<Personne> findPersonneEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery("select object(o) from Personne as o");
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Personne findPersonne(Long id) {
EntityManager em = getEntityManager();
try {
return em.find(Personne.class, id);
} finally {
em.close();
}
}
public int getPersonneCount() {
EntityManager em = getEntityManager();
try {
return ((Long) em.createQuery("select count(o) from Personne as o").getSingleResult()).intValue();
} finally {
em.close();
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| package gestionpersonne;
/**
*
* @author linuxien
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Personne p = new Personne("alex");
PersonneJpaController controller = new PersonneJpaController();
controller.create(p);
}
} |
je precise que la lib toplink essentials est ajoutée :cry:
http://farm4.static.flickr.com/3353/...c69bba.jpg?v=0
et que ca se connecte avec netbeans :evilred:
http://farm4.static.flickr.com/3129/...ed218a.jpg?v=0
merci d'avance