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

Groovy Java Discussion :

Connexion avec MySQL


Sujet :

Groovy Java

  1. #1
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2012
    Messages : 12
    Points : 14
    Points
    14
    Par défaut Connexion avec MySQL
    Bonjour,
    J'ai commencé depuis hier à créer un programme en Groovy comme vous pouvez donc le comprendre je suis débutant .

    1) Voila je vous explique tout d'abord de que j'ai fait :
    J'utilise SpringSource Tool.

    Par défaut, Grails se branche sur une base de données HSQLDB.
    Or je préfère utiliser MySQL.

    Pour me connecter à mon MySQL via Grails j'ai donc dans le fichier DataSource.groovy modifié :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    dataSource {
        pooled = true
        driverClassName = "org.mysql.Driver" <--- Ici car j'utilise mysql
        username = "root" <--- Ici mon nom d'utilisateur
        password = "confidentiel" <--- Mon code
    }
    (...)
    dataSource {
                dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', '' <--- Update pour que la base de donnée se mette a jour automatiquement
                url = "jdbc:mysql:///sql5/mabase:3306" <--- L'url de mon mysql ( je penses :?)
            }
    De plus j'ai mis le .jar : mysql-connector-java-5.1.11-bin.jar dans le lib de mon projet car j'utilise la version 5.1.11 de MySQL.


    2) Maintenant voici le message d'erreur que j'obtient :
    Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.Driver'
    <---- En raccourci car j'ai ce message sur environ 3 pages. Je penses que c'est ici que ca bug.Est ce que quelqu'un pourrait me venir en aide s'il vous plait?

  2. #2
    Membre émérite
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Points : 2 969
    Points
    2 969
    Par défaut
    Bonjour,

    Le driver à utiliser est com.mysql.jdbc.Driver ?

    Cf. doc officielle : http://dev.mysql.com/doc/refman/5.1/...roperties.html
    Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

    F.A.Q. : Java, PHP, (X)HTML / CSS

    N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème

  3. #3
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2012
    Messages : 12
    Points : 14
    Points
    14
    Par défaut
    Effectivement, entre temps j'ai modifié, mais j'ai toujours le même message d'erreur.
    J'ai trouvé pas mal de tutorat qui me dise de modifier le fichier DataSource.groovy et tous de cette manière :
    [
    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
    30
    31
    32
    33
    34
    35
     
    dataSource {
       pooled = true
        driverClassName = "org.mysql.jdbc.Driver"
    	username = "root"
    	password="sopra123"
    }
     
    hibernate {
        cache.use_second_level_cache = true
        cache.use_query_cache = true
        cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
    }
    // environment specific settings
    environments {
        development {
            dataSource {
                dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
                url = "jdbc:mysql://localhost:3306/foot_dev"
    			show_sql=true
            }
        }
        test {
            dataSource {
                dbCreate = "update"
    			url = "jdbc:mysql://localhost:3306/foot_test"
            }
        }
    	production {
    		dataSource {
    			dbCreate = "update"
    			url = "jdbc:mysql://localhost:3306/foot"
    		}
    	}
    }
    Je suis exactement ce que me dit le tutorat et pourtant j'ai toujours et encore la même erreur...

    voila grosso toute l'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
    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
     
     Error 2012-06-28 17:26:40,184 [pool-7-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
        Line | Method
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by SQLNestedException: Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
    ->> 1429 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |   1371 | createDataSource in     ''
    |   1044 | getConnection in     ''
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run . . . in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run       in java.lang.Thread
    Caused by ClassNotFoundException: org.mysql.jdbc.Driver
    ->>  366 | run       in java.net.URLClassLoader$1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    355 | run       in     ''
    |    354 | findClass in java.net.URLClassLoader
    |    423 | loadClass in java.lang.ClassLoader
    |    356 | loadClass in     ''
    |   1420 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
    |   1371 | createDataSource in     ''
    |   1044 | getConnection in     ''
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run       in java.util.concurrent.FutureTask
    |   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread

  4. #4
    Membre émérite
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Points : 2 969
    Points
    2 969
    Par défaut
    Le fichier mysql-connector-java-5.1.11-bin.jar est-il bien pris en compte dans le classpath ?

    Il ne suffit peut-être pas de le mettre dans le répertoire lib ? Une configuration supplémentaire est peut-être nécessaire.
    Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

    F.A.Q. : Java, PHP, (X)HTML / CSS

    N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème

  5. #5
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2012
    Messages : 12
    Points : 14
    Points
    14
    Par défaut
    J'avais éffectivement déjà mis le mysql-connector-java-5.1.11-bin.jar dans le classpath... Je n'arrives toujours pas à résoudre mon problème

  6. #6
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2012
    Messages : 12
    Points : 14
    Points
    14
    Par défaut
    Je vous tiendrais au courant si j'arrive à résoudre mon problème.
    J'ai aussi essayer avec deux autres version différentes du connecteur sans grand succès.

  7. #7
    Membre à l'essai
    Homme Profil pro
    Étudiant
    Inscrit en
    Juin 2012
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2012
    Messages : 12
    Points : 14
    Points
    14
    Par défaut
    j'ai une bonne nouvelle, j'ai résolution le problème en réalité dans le fichier :
    DataSourcee.groovy il ne fallait pas mettre :
    driverClassName="org.mysql.jdbc.Driver"
    mais
    driverClassName="com.mysql.jdbc.Driver"
    car dans le mysql-connector-java-5.1.18-bin.jar , il n'y avait pas de lien org.mysql.jdbc.Driver
    Je ne sais pas si j'ai été claire dans mon explication en tout cas cela reste un grand mystère pour moi

    J'ai maintenant un nouveau soucis mais je vais essayer de me débrouiller par mes propres moyens merci beaucoup et bon courage...

  8. #8
    Membre émérite
    Avatar de Nesmontou
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Septembre 2004
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Finance

    Informations forums :
    Inscription : Septembre 2004
    Messages : 1 612
    Points : 2 969
    Points
    2 969
    Par défaut
    En effet

    Citation Envoyé par Nesmontou Voir le message
    Bonjour,

    Le driver à utiliser est com.mysql.jdbc.Driver ?

    Cf. doc officielle : http://dev.mysql.com/doc/refman/5.1/...roperties.html
    Si vous ne pouvez expliquer un concept à un enfant de six ans, c'est que vous ne le comprenez pas complètement. Albert EINSTEIN

    F.A.Q. : Java, PHP, (X)HTML / CSS

    N'oubliez pas de cliquer sur le bouton Résolu en bas de page quand vous avez obtenu une solution à votre problème

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Pb avec la connexion avec MySql
    Par rezguiii dans le forum Wildfly/JBoss
    Réponses: 1
    Dernier message: 22/02/2007, 22h26
  2. [pool de connexion] avec mysql et eclipse
    Par Mascotte dans le forum Servlets/JSP
    Réponses: 16
    Dernier message: 15/02/2007, 15h02
  3. Erreur de connexion avec Mysql -> Driver bugué
    Par kedare dans le forum Général Dotnet
    Réponses: 2
    Dernier message: 07/02/2007, 08h47
  4. Pas de connexion avec MySQL ?
    Par spekal dans le forum JDBC
    Réponses: 15
    Dernier message: 23/01/2007, 18h38
  5. [SGBD] Problème de connexion avec mysql
    Par weshwesh dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 29/06/2006, 10h30

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