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

Tests et Performance Java Discussion :

[ANT / DbUnit / MySql] Import ne fonctionne pas ?


Sujet :

Tests et Performance Java

  1. #1
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut [ANT / DbUnit / MySql] Import ne fonctionne pas ?
    Bonsoir

    Je souhaite utiliser ANT1.7.1 et DBUNIT 2.4.8 pour charger des données dans ma Base Mysql
    Le script se deroule en successfull, mais rien n'est inséré.
    J'ai testé une insertion JDBC avec le meme driver sur la meme base qui fonctionne.

    Mon script ant
    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
     
    - <project name="project1" default="import" basedir="..">
    - <taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask">
    - <classpath>
      <path location="./lib/mysql-connector-java-5.1.14-bin.jar" /> 
      <path location="./lib/antlr-2.7.6.jar" /> 
      <path location="./lib/dbunit-2.4.8.jar" /> 
      <path location="./lib/commons-collections-3.1.jar" /> 
    - <!--  <path location="./lib/commons-logging-1.1.1.jar"/> 
      --> 
      <path location="./lib/dom4j-1.6.1.jar" /> 
      <path location="./lib/log4j-1.2.16.jar" /> 
      <path location="./lib/slf4j-api-1.5.6.jar" /> 
      <path location="./lib/slf4j-log4j12-1.5.2.jar" /> 
      </classpath>
      </taskdef>
      <typedef resource="org/dbunit/ant/antlib.xml" /> 
    - <target name="import" description="Recreates global tables in MYSQL from XML files" depends="">
    - <dbunit driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.17.4:3306/employes" userid="gestion" password="gestion">
     
      <operation type="INSERT" src="/prj_java/TestAgarder/hibernate4/data/init_data.xml" format="xml" /> 
      </dbunit>
      <echo message="apres" /> 
      </target>
      </project>
    Mon log
    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
     
    Build sequence for target(s) `import' is [import]
    Complete build sequence is [import, ]
     
    import:
       [dbunit] log4j:WARN No appenders could be found for logger (org.dbunit.ant.Op
    eration).
       [dbunit] log4j:WARN Please initialize the log4j system properly.
       [dbunit] log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig
     for more info.
       [dbunit] Loading com.mysql.jdbc.Driver using system loader.
       [dbunit] connecting to jdbc:mysql://192.168.17.4:3306/employes
       [dbunit] Created connection for schema 'null' with config: org.dbunit.databas
    e.DatabaseConfig[, _propertyMap={http://www.dbunit.org/properties/statementFacto
    ry=org.dbunit.database.statement.PreparedStatementFactory@66e815, http://www.dbu
    nit.org/features/caseSensitiveTableNames=false, http://www.dbunit.org/properties
    /fetchSize=100, http://www.dbunit.org/features/batchedStatements=false, http://w
    ww.dbunit.org/properties/metadataHandler=org.dbunit.database.DefaultMetadataHand
    ler@ece65, http://www.dbunit.org/properties/datatypeFactory=org.dbunit.dataset.d
    atatype.DefaultDataTypeFactory[_toleratedDeltaMap=org.dbunit.dataset.datatype.To
    leratedDeltaMap@106082], http://www.dbunit.org/properties/escapePattern=null, ht
    tp://www.dbunit.org/properties/batchSize=100, http://www.dbunit.org/features/qua
    lifiedTableNames=false, http://www.dbunit.org/properties/tableType=[Ljava.lang.S
    tring;@1301ed8, http://www.dbunit.org/properties/resultSetTableFactory=org.dbuni
    t.database.ForwardOnlyResultSetTableFactory@3901c6, http://www.dbunit.org/featur
    es/datatypeWarning=true}]
       [dbunit] Executing operation: INSERT
       [dbunit]           on   file: C:\prj_java\TestAgarder\hibernate4\data\init_da
    ta.xml
       [dbunit]           with format: xml
         [echo] apres
     
    BUILD SUCCESSFUL
    Total time: 0 seconds
    Mon fichier XML init_data.xml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <?xml version="1.0" encoding="UTF-8"?>
    <dataset>
     
    <TEST1 TEST_ID="6" NOM="TESTC" COUNT="6"/>
    </dataset>
    Une insertion par JDBC fonctionne bien ?
    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
     
        public static void main(String[] args) {
     
            try {
     
                String url      = "jdbc:mysql://192.168.17.4:3306/employes";                String user     = "gestion";                                  
                String password = "gestion";
     
                Class.forName("com.mysql.jdbc.Driver");
                       Connection con = DriverManager.getConnection(url, user, password);
     
                 con.setAutoCommit(false);
     
                // create prepared statement
                try {
     
                    String            sql       = "INSERT INTO test1 (TEST_ID,NOM,COUNT) VALUES(?,?,?)";
                    PreparedStatement statement = con.prepareStatement(sql);
     
                    // en sp�cifiant bien les types SQL cibles
                    printd("avant premier insert");
                  statement.setObject(1, new Integer(5), Types.INTEGER);
                    statement.setObject(2, "nom", Types.VARCHAR);
                    statement.setObject(3, new Integer(5), Types.INTEGER);
     
                    statement.executeUpdate();
                    statement.close();
                    con.commit();
                    con.close();
                } catch (SQLException e) {
                   printd(e.getMessage());
                }
            } catch (Exception e1) {
                printd("Erreur Message=" + e1.getMessage());
                e1.printStackTrace();
            }
        }
    Ou est mon erreur dans la compréhension de DBUNIT ?

    Le tutorial d'ou je suis parti
    http://dbunit.sourceforge.net/anttask.html

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 705
    Points : 934
    Points
    934
    Par défaut
    Bonsoir

    Pb Resolu
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <dbconfig>
     <property name="datatypeFactory" value="org.dbunit.ext.mysql.MySqlDataTypeFactory"/> 
                        <property name="metadataHandler" value="org.dbunit.ext.mysql.MySqlMetadataHandler"/> 
                        <feature name="qualifiedTableNames" value="false"/>
    </dbconfig>

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

Discussions similaires

  1. TALEND : La fonction Export / Import ne fonctionne pas
    Par chebdo dans le forum Installation, migration et administration
    Réponses: 2
    Dernier message: 30/05/2011, 17h03
  2. Fonction mysql qui ne fonctionne pas pour un ancien postgreIste
    Par floreasy dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 15/01/2008, 18h49
  3. Requete MySQL qui ne fonctionne pas
    Par bzhades dans le forum Débuter
    Réponses: 14
    Dernier message: 10/05/2007, 18h19
  4. mysql rand() ne fonctionne pas
    Par renaud26 dans le forum Requêtes
    Réponses: 4
    Dernier message: 28/09/2006, 16h54
  5. ma feuille javascript importée ne fonctionne pas
    Par psychoBob dans le forum Général JavaScript
    Réponses: 17
    Dernier message: 08/06/2006, 09h07

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