IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JPA Java Discussion :

executer première jpa


Sujet :

JPA Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Inscrit en
    Avril 2007
    Messages
    679
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 679
    Par défaut executer première jpa
    bonjour,

    je débute avec jpa et je ne suis pas arrivé a générer mon entité en exécutant la classe principale main

    je vous montre l'entité
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    import java.io.Serializable;
    import java.lang.Long;
    import java.lang.String;
    import javax.persistence.*;
    public class Formation implements Serializable {
    	private Long id;
    	private String theme;
    	private static final long serialVersionUID = 1L;
     
    	public Formation() {
    		super();
    	}   
    	public Long getId() {
    		return this.id;
    	}
     
    	public void setId(Long id) {
    		this.id = id;
    	}   
    	public String getTheme() {
    		return this.theme;
    	}
     
    	public void setTheme(String theme) {
    		this.theme = theme;
    	}
     
    }
    et la classe principale
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
     
     
    public class DemoJpa {
    public static void main(String[] args) {
    EntityManagerFactory emf=Persistence.createEntityManagerFactory("demojpa");
    EntityManager em = emf.createEntityManager();
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    Formation formation= new  Formation();
    tx.commit();
    em.close();
    emf.close();
    }
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
     
     
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.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_2_0.xsd">
    	<persistence-unit name="demojpa">
     
    	<properties>
                <property name="hibernate.archive.autodetection" value="class" />
                <!-- <property name="hibernate.show_sql" value="true" /> -->
                <property name="hibernate.format_sql" value="true" />
     
                <!-- Configuration de la  BDD -->
                <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" />
                <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:FIN" />
                <property name="hibernate.connection.username" value="DO" />
                <property name="hibernate.connection.password" value="DO" />
     
                <!-- Spécifie le 'dialecte' SQL utilisé pour communiquer avec la BDD -->
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
                 <!-- Indique a Hibernate de (re-)créer la BDD au lancement de l'application -->
                <property name="hibernate.hbm2ddl.auto" value="create" />
            </properties>
    	</persistence-unit>
    </persistence>
    une fois lancer run une fenêtre message d'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named demojpa
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:69)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
    	at DemoJpa.main(DemoJpa.java:10)
    merci d'avance

  2. #2
    Membre éclairé
    Inscrit en
    Avril 2007
    Messages
    679
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 679
    Par défaut
    j'ai essayé de résoudre problème j'ai message d'erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     
    [EL Info]: 2013-04-11 15:11:39.808--ServerSession(14074220)--EclipseLink, version: Eclipse Persistence Services - 2.4.1.v20121003-ad44345
    [EL Severe]: ejb: 2013-04-11 15:11:39.824--ServerSession(14074220)--Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
    Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
    Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:602)
    	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:186)
    	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:278)
    	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:304)
    	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:282)
    	at mus.main(mus.java:13)
    Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
    Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platform
    	at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:376)
    	at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91)
    	at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    	at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:685)
    	at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:215)
    	at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:542)
    	... 5 more

  3. #3
    Membre éclairé
    Inscrit en
    Avril 2007
    Messages
    679
    Détails du profil
    Informations forums :
    Inscription : Avril 2007
    Messages : 679
    Par défaut
    JE VOUS MONTRE FICHIER PERSISTENCE.XML
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.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_2_0.xsd">
    	<persistence-unit name="test">
    		<class>Diplome</class>
    		<properties>
             <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@10.133.0.25:1521:FIN"/>
            <property name="toplink.jdbc.user" value="DEVRTO"/>
            <property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
            <property name="toplink.jdbc.password" value="DEVRTO"/>
           </properties>
    	</persistence-unit>
    </persistence>

Discussions similaires

  1. Arrêter l'execution à la première erreur
    Par Kirata dans le forum SAS Base
    Réponses: 3
    Dernier message: 07/12/2012, 14h58
  2. [WebFlow] 1 transition, 2 expressions, mais la première n'est pas executée
    Par erox44 dans le forum Spring Web
    Réponses: 0
    Dernier message: 25/10/2012, 12h02
  3. [WD14] Code pour la première execution du projet
    Par Deallyra dans le forum WinDev
    Réponses: 4
    Dernier message: 15/07/2009, 17h38
  4. plantage programme lors de sa première execution
    Par goffle dans le forum Code::Blocks
    Réponses: 1
    Dernier message: 12/11/2008, 18h25
  5. Lenteurs Sharepoint à la première execution quotidienne
    Par Mirror69 dans le forum SharePoint
    Réponses: 1
    Dernier message: 16/03/2008, 21h46

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo