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

JDBC Java Discussion :

Problème de connection à la BD Mysql via Java


Sujet :

JDBC Java

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut Problème de connection à la BD Mysql via Java
    Bonjour,

    je me suis basé sur ce tuto : http://defaut.developpez.com/tutorie...pse/hibernate/
    pour effectuer une connection une connection à la BD mysql. Comme le tuto j'ai créer le fichier de configuration et mapping hibernate avec le driver Mysql : com.mysql.jdbc.Driver
    Adresse de la base : jdbc:mysql://127.0.0.1:3306/test

    Ensuite j'ai créer une programme Test :

    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
    package ConnectionHibernate; 
     
    import hibernate.Table; 
    import net.sf.hibernate.HibernateException; 
    import net.sf.hibernate.Session; 
    import net.sf.hibernate.Transaction; 
     
    public class Test { 
     
    public static void main(String[] args) throws HibernateException { 
     
    Session session = HibernateUtil.currentSession(); 
    Transaction tx = session.beginTransaction(); 
    Table table = new Table(); 
    table.setNom("Nom"); 
    table.setPrenom("Prenom"); 
    table.setAge(12); 
    session.save(table); 
    tx.commit(); 
    HibernateUtil.closeSession(); 
     
    } 
    }

    A l'execution de ce programme j'ai cette erreur qui dit à priori que le driver Mysql n'est pas bon:


    Exception in thread "main" net.sf.hibernate.JDBCException: Cannot open connection
    at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:289)
    at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3326)
    at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3286)
    at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
    at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactor y.java:19)
    at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2231)
    at ConnectionHibernate.Test.main(Test.java:16)
    Caused by: java.sql.SQLException: No suitable driver found for
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at net.sf.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerCon nectionProvider.java:101)
    at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:286)
    ... 6 more

    Quelqu'un pourrai m'aider svp ?

    Merci

    PS: configuration : jre1.6.3, Tomcat6, hibernate2.jar, EasyPhp2.0b1, mysql-connector-java-5.0.8-bin

  2. #2
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Fais voir le fichier de configuration d'hibernate

    Et verifie tes parmetres de connexion, chaine de connexion, user , mot de passe ...

  3. #3
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    Bonjour,

    Merci d'avoir répondu. enfaite j'utilise le hibernate synchronizer qui est généré automatiquement donc normalement ça devrait être bon :


    Code xml : 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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
     
    <hibernate-configuration>
    	<session-factory>
     
    		<!-- local connection properties -->
    		<property name="hibernate.connection.url"></property>
    		<property name="hibernate.connection.driver_class">
    			com.mysql.jdbc.Driver
    		</property>
    		<property name="hibernate.connection.username">root</property>
    		<property name="hibernate.connection.password"></property>
    		<!-- property name="hibernate.connection.pool_size"></property -->
     
    		<!-- dialect for MySQL -->
    		<property name="dialect">
    			net.sf.hibernate.dialect.MySQLDialect
    		</property>
     
    		<property name="hibernate.show_sql">false</property>
    		<property name="hibernate.use_outer_join">true</property>
    			<!--
    			<property name="hibernate.transaction.factory_class">
    			net.sf.hibernate.transaction.JTATransactionFactory
    			</property>
    			<property name="jta.UserTransaction">
    			java:comp/UserTransaction
    			</property>
    		//-->
    		<property name="hibernate.transaction.factory_class">
    			net.sf.hibernate.transaction.JDBCTransactionFactory
    		</property>
     
    			<mapping resource="Table.hbm" />
     
     
    	</session-factory>
    </hibernate-configuration>


    ####################################################

    et voici le fichier de mapping hibernate :


    Code xml : 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
    30
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    	"-//Hibernate/Hibernate Mapping DTD//EN"
    	"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
     
    <hibernate-mapping package="hibernate">
    	<class name="Table" table="table">
    		<id
    			column="Nom"
    			name="Nom"
    			type="string"
    		>
    			<generator class="vm" />
    		</id>
    		<property
    			column="Age"
    			length="10"
    			name="Age"
    			not-null="true"
    			type="integer"
    		 />
    		<property
    			column="Prenom"
    			length="20"
    			name="Prenom"
    			not-null="true"
    			type="string"
    		 />
    	</class>
    </hibernate-mapping>



    je l'ai lancé en debug le programme d'execution 'Test' et c'est au niveau de cette ligne que ça plante :

    Transaction tx = session.beginTransaction();



    Encore une fois c'est gentil de t'as part d'avoir répondu

    Merci

  4. #4
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Ah Ok, j'avais pas bien regarder la trace de ton erreur :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Caused by: java.sql.SQLException: No suitable driver found for
    Ton driver JDBC n'est pas trouvé. Cela veut dire qu'il doit etre absent du classpath de ton projet.

  5. #5
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    Pourtant j'ai bien ajouté le fichier jar 'mysql-connector-java-5.0.8-bin.jar' dans la liste des librairies. Faut-il ajouter autre chose?

    Merci

  6. #6
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Ton application est en local ou passe par un serveur genre Tomcat ?

  7. #7
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    Bonjour,

    c'est une appli serveur Tomcat. j'avais des pages jsp des servlets créér. J'ai créer un autre projet Dynamic Web Projet et j'ai mis juste les codes copier précedamment et la j'ai un autre erreur :


    Exception in thread "main" net.sf.hibernate.exception.SQLGrammarException: Could not save object
    at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
    at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:794)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at Test.main(Test.java:21)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Erreur de syntaxe près de 'table' à la ligne 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
    at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:67)
    at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776)
    ... 2 more


    ##############################################""

    je ne sais pas d'ou ca provient cet erreur:

    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Erreur de syntaxe près de 'table' à la ligne 1

  8. #8
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Pour ta derniere erreur, je ne sais pas trop.

    Mais par contre, dans le premier cas il faut mettre le driver jdbc dans le dossier des librairies de Tomcat.

  9. #9
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    c'était bien ça la premiere erreur. je dois voir maintenant comment résouder la seconde.

    Merci pour m'avoir aider

  10. #10
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Pour la deuxieme, je crois que c'est parce que tu utilies un generateur d'identifiant et que tu lui affectes une valeur.

  11. #11
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    Enfaite je voulais juste tester pour voir si je peux sauvgarder des infos dans la BD donc j'ai créer une table avec Nom,Prenom,Age avec Nom comme clé primaire(meme si c'est pas cohérant!). Ou est ce que je crée un générateur d'identifiant? Au niveau du fichier de mapping hibernate "Table.hbm" tu veux dire plus précisement cette ligne ?

    <generator class="vm" />

    Qu'est ce qu'il faut que je fasse?

    merci

  12. #12
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Ben ca depend, s tu veux que la base genere ses identifiants tu la laisse faire, mais je doute que pour le nom ce soit le cas.

    Alors le mieux c'est que tu l'enleves.

    Eventuellement, tu crees un identifiant qui ne soit pas le nom, un id interne.

  13. #13
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    C'est ce que j'ai fait mais ca n'a pas l'air de marcher :


    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

    <hibernate-mapping package="hibernate">
    <class
    name="Table"
    table="table"
    >
    <id
    name="Id"
    type="integer"
    column="Id"
    >
    <generator class="vm"/>
    </id>

    <property
    name="Nom"
    column="Nom"
    type="string"
    not-null="true"
    length="20"
    />
    <property
    name="Age"
    column="Age"
    type="integer"
    not-null="true"
    length="10"
    />
    <property
    name="Prenom"
    column="Prenom"
    type="string"
    not-null="true"
    length="20"
    />


    </class>
    </hibernate-mapping>


    j'ai tjs cet erreur :

    Exception in thread "main" net.sf.hibernate.exception.SQLGrammarException: Could not save object
    at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
    at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:794)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at Test.main(Test.java:21)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Erreur de syntaxe près de 'table' à la ligne 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
    at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:67)
    at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776)
    ... 2 more


  14. #14
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    et voici le programme d'execution :

    public class Test {

    public static void main(String[] args) throws HibernateException {

    Session session = HibernateUtil.currentSession();
    Transaction tx = session.beginTransaction();
    Table table = new Table();
    table.setNom("Nom");
    table.setPrenom("Prenom");
    table.setAge(new Integer(23));
    session.save(table);
    tx.commit();
    HibernateUtil.closeSession();
    }
    }

  15. #15
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    j'ai mis <generator class="increment" />
    au lieu de <generator class="increment" /> ca ne marche tjs pas

  16. #16
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    <generator class="increment" /> au lieu de <generator class="vm" />

  17. #17
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Ne mets rien!

  18. #18
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    si je met rien ca donne ca :

    Exception in thread "main" java.lang.ExceptionInInitializerError
    at Test.main(Test.java:15)
    Caused by: java.lang.RuntimeException: Problème de configuration : Error reading resource: Table.hbm
    at HibernateUtil.<clinit>(HibernateUtil.java:17)
    ... 1 more
    Caused by: net.sf.hibernate.MappingException: Error reading resource: Table.hbm
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:340)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1027)
    at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:983)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:911)
    at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
    at HibernateUtil.<clinit>(HibernateUtil.java:14)
    ... 1 more
    Caused by: net.sf.hibernate.MappingException: invalid mapping
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:288)
    at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:337)
    ... 6 more
    Caused by: org.xml.sax.SAXParseException: The content of element type "id" is incomplete, it must match "(meta*,column*,generator)".
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.dom4j.io.SAXReader.read(SAXReader.java:334)
    at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
    ... 7 more

  19. #19
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Essaye avec

    <generator class="assigned" />


    va faire un tour ici, y'a des infos pour le configurer :

    http://www.hibernate.org/hib_docs/v3...declaration-id

  20. #20
    Candidat au Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    17
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2007
    Messages : 17
    Points : 3
    Points
    3
    Par défaut
    j'ai esseyé avec <generator class="native" /> et <generator class="identity"/>
    j'ai cet erreur :


    Exception in thread "main" net.sf.hibernate.exception.SQLGrammarException: could not insert: [hibernate.Table]
    at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
    at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
    at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:540)
    at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:426)
    at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:28)
    at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2449)
    at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:943)
    at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:868)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:786)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at Test.main(Test.java:25)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Erreur de syntaxe près de 'table (Nom, Age, Prenom) values ('Nom', 23, 'Prenom')' à la ligne 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504)
    at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:518)
    ... 8 more


    pour "sequence", "native" cet erreur :

    Exception in thread "main" net.sf.hibernate.exception.SQLGrammarException: Could not save object
    at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:69)
    at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4131)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:794)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at Test.main(Test.java:25)
    Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Erreur de syntaxe près de 'table' à la ligne 1
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1467)
    at net.sf.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:67)
    at net.sf.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:42)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776)
    ... 2 more

    pour "assigned"


    Exception in thread "main" net.sf.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): hibernate.Table
    at net.sf.hibernate.id.Assigned.generate(Assigned.java:26)
    at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:776)
    at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:749)
    at Test.main(Test.java:25)

Discussions similaires

  1. Problème de connexion à la base MYSQL via l'exécutable .JAR
    Par sam45 dans le forum Interfaces Graphiques en Java
    Réponses: 8
    Dernier message: 12/09/2008, 14h48
  2. [VB.net] Problème de connection à ma base MySQL
    Par WriteLN dans le forum Windows Forms
    Réponses: 3
    Dernier message: 02/01/2008, 17h14
  3. Problème : hibernate.connection.url jdbc:mysql
    Par doudou_angelus dans le forum Hibernate
    Réponses: 3
    Dernier message: 22/08/2007, 13h58
  4. pb de creation procedure Mysql via java
    Par metos00 dans le forum JDBC
    Réponses: 1
    Dernier message: 09/07/2007, 10h33
  5. se connecter à une base mysql via access
    Par Thom N2h dans le forum Access
    Réponses: 3
    Dernier message: 28/11/2005, 23h54

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