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

Documents Java Discussion :

java et jasperReport


Sujet :

Documents Java

  1. #1
    Membre averti
    Inscrit en
    Novembre 2007
    Messages
    16
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 16
    Par défaut java et jasperReport
    salut;
    j'essaye de créer un rapport à l'aide de iReport et l'integré dans un code java.
    et voila une partie de mon 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
     
    5 juin 2011 22:59:41 org.apache.commons.digester.Digester error
    GRAVE: Parse Error at line 2 column 408: Document root element "jasperReport", must match DOCTYPE root "null".
    org.xml.sax.SAXParseException: Document root element "jasperReport", must match DOCTYPE root "null".
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.rootElementSpecified(XMLDTDValidator.java:1621)
    	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1900)
    	at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:764)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$ContentDriver.scanRootElementHook(XMLDocumentScannerImpl.java:1318)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    et mon code java:

    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
     
    String url = "jdbc:oracle:thin:@localhost:1521:gpsi";
        String user = "gestion";
        String passwd = "password";
        Connection conn = null;
     
        String reference = this.commande_reference.getText();
     
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = DriverManager.getConnection(url, user, passwd);
            Statement stmt = conn.createStatement();
     
            JasperDesign jasperDesign = JRXmlLoader.load("./lib/report.jrxml");
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            Map parameters = new HashMap();
     
            parameters.put("ref",reference);        
     
             JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn);
     
            net.sf.jasperreports.view.JasperViewer.viewReport(jasperPrint,false);
            // - Création du rapport au format PDF
            //JasperExportManager.exportReportToPdfFile(jasperPrint, "./lib/report.pdf");
     
            JOptionPane.showMessageDialog(this , "Opération éffectuée avec succès!", "Terminé" , JOptionPane.INFORMATION_MESSAGE)  ;
     
        } catch (JRException ex) {
            Logger.getLogger(Recherche_commande.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(this, "erreur : Opération non effectuées " +
                    ex.getMessage()  , "Avertissement", JOptionPane.ERROR_MESSAGE);
        } catch (ClassNotFoundException ex) {
            JOptionPane.showMessageDialog(this, "erreur : Opération non effectuées " +
                    ex.getMessage()  , "Avertissement", JOptionPane.ERROR_MESSAGE);
        }finally {
            try {
                 conn.close();
                } catch (SQLException e) {
     
                        e.printStackTrace();
                }
        }
    et pour le contenu de mon fichier JRXML:
    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
    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
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
        <property name="ireport.zoom" value="1.0"/>
        <property name="ireport.x" value="0"/>
        <property name="ireport.y" value="0"/>
        <parameter name="ref" class="java.lang.String"/>
        <queryString>
            <![CDATA[SELECT
                    ASSOCIER."QUANTITE",
                    CLIENTS."CLIENTNOM",
                    PRODUITS."PRODUITNOM",
                    COMMANDES."REFERENCE",
                    COMMANDES."COMMANDEDATE",
                    CLIENTS."CLIENTPRENOM" AS CLIENTS_CLIENTPRENOM,
                    sum(PRODUITS.produitprix*ASSOCIER.quantite)
            FROM
                    "COMMANDES" COMMANDES,
                    "EMPLOYES" EMPLOYES,
                    "CLIENTS" CLIENTS,
                    "PAIEMENTS" PAIEMENTS,
                    "ASSOCIER" ASSOCIER,
                    "PRODUITS" PRODUITS
            WHERE
                    COMMANDES.employeid = EMPLOYES.employeid
                    and CLIENTS.clientid = COMMANDES.clientid
                    and COMMANDES.commandeid = PAIEMENTS.commandeid
                    and COMMANDES.commandeid = ASSOCIER.commandeid
                    and PRODUITS.produitid = ASSOCIER.produitid
                    and COMMANDES.reference = '$P!{ref}'
            GROUP BY
                    PRODUITS.produitnom,
                    COMMANDES.reference,
                    CLIENTS.clientnom,
                    CLIENTS.clientprenom,
                    EMPLOYES.employenom,
                    COMMANDES.commandedate,
                    PAIEMENTS.paiementdate,
                    ASSOCIER.quantite]]>
        </queryString>
        <field name="QUANTITE" class="java.math.BigDecimal"/>
        <field name="CLIENTNOM" class="java.lang.String"/>
        <field name="PRODUITNOM" class="java.lang.String"/>
        <field name="REFERENCE" class="java.lang.String"/>
        <field name="COMMANDEDATE" class="java.sql.Timestamp"/>
        <field name="CLIENTS_CLIENTPRENOM" class="java.lang.String"/>
        <field name="SUM(PRODUITS.PRODUITPRIX*ASSOCIER.QUANTITE)" class="java.math.BigDecimal"/>
        <group name="REFERENCE">
            <groupExpression><![CDATA[$F{REFERENCE}]]></groupExpression>
        </group>
        <background>
            <band splitType="Stretch"/>
        </background>
        <title>
            <band height="143" splitType="Stretch">
                <staticText>
                    <reportElement x="183" y="25" width="222" height="92"/>
                    <textElement>
                        <font fontName="Andalus" size="60"/>
                    </textElement>
                    <text><![CDATA[Facture]]></text>
                </staticText>
                <line>
                    <reportElement x="15" y="121" width="527" height="1"/>
                    <graphicElement>
                        <pen lineWidth="2.0" lineStyle="Double"/>
                    </graphicElement>
                </line>
            </band>
        </title>
        <pageHeader>
            <band height="35" splitType="Stretch">
                <staticText>
                    <reportElement x="17" y="7" width="100" height="20"/>
                    <textElement/>
                    <text><![CDATA[Reference :]]></text>
                </staticText>
                <staticText>
                    <reportElement x="310" y="9" width="100" height="20"/>
                    <textElement/>
                    <text><![CDATA[Date :]]></text>
                </staticText>
                <textField>
                    <reportElement mode="Transparent" x="127" y="7" width="100" height="20" backcolor="#FFFFFF"/>
                    <textElement/>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{REFERENCE}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="423" y="7" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression class="java.sql.Timestamp"><![CDATA[$F{COMMANDEDATE}]]></textFieldExpression>
                </textField>
            </band>
        </pageHeader>
        <columnHeader>
            <band height="61" splitType="Stretch">
                <staticText>
                    <reportElement x="17" y="10" width="100" height="20"/>
                    <textElement/>
                    <text><![CDATA[Nom de client :]]></text>
                </staticText>
                <textField>
                    <reportElement x="127" y="10" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{CLIENTNOM}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement x="307" y="10" width="100" height="20"/>
                    <textElement/>
                    <text><![CDATA[Prenom de  client :]]></text>
                </staticText>
                <textField>
                    <reportElement x="423" y="10" width="100" height="20"/>
                    <textElement/>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{CLIENTS_CLIENTPRENOM}]]></textFieldExpression>
                </textField>
                <line>
                    <reportElement x="-19" y="30" width="595" height="1" forecolor="#666666"/>
                </line>
                <staticText>
                    <reportElement mode="Opaque" x="323" y="41" width="143" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
                    <textElement textAlignment="Center">
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[SUM(PRODUITS.PRODUITPRIX*ASSOCIER.QUANTITE)]]></text>
                </staticText>
                <staticText>
                    <reportElement mode="Opaque" x="204" y="41" width="119" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
                    <textElement textAlignment="Center">
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[QUANTITE]]></text>
                </staticText>
                <staticText>
                    <reportElement mode="Opaque" x="73" y="41" width="131" height="20" forecolor="#006699" backcolor="#E6E6E6"/>
                    <textElement textAlignment="Center">
                        <font size="12" isBold="true"/>
                    </textElement>
                    <text><![CDATA[PRODUITNOM]]></text>
                </staticText>
            </band>
        </columnHeader>
        <detail>
            <band height="49" splitType="Stretch">
                <textField>
                    <reportElement mode="Transparent" x="73" y="0" width="131" height="20" backcolor="#9999FF"/>
                    <textElement/>
                    <textFieldExpression class="java.lang.String"><![CDATA[$F{PRODUITNOM}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="324" y="0" width="142" height="20"/>
                    <textElement/>
                    <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{SUM(PRODUITS.PRODUITPRIX*ASSOCIER.QUANTITE)}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement x="204" y="0" width="120" height="20"/>
                    <textElement/>
                    <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{QUANTITE}]]></textFieldExpression>
                </textField>
                <line>
                    <reportElement x="73" y="0" width="393" height="1"/>
                </line>
                <line>
                    <reportElement x="204" y="1" width="1" height="19"/>
                </line>
            </band>
        </detail>
        <pageFooter>
            <band height="30" splitType="Stretch">
                <textField>
                    <reportElement mode="Opaque" x="0" y="15" width="515" height="13" backcolor="#E6E6E6"/>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression class="java.lang.String"><![CDATA["Page "+$V{PAGE_NUMBER}+" of"]]></textFieldExpression>
                </textField>
                <textField evaluationTime="Report">
                    <reportElement mode="Opaque" x="515" y="15" width="40" height="13" backcolor="#E6E6E6"/>
                    <textElement/>
                    <textFieldExpression class="java.lang.String"><![CDATA[" " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
                <textField pattern="EEEEE dd MMMMM yyyy">
                    <reportElement x="0" y="15" width="100" height="13"/>
                    <textElement/>
                    <textFieldExpression class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
                </textField>
            </band>
        </pageFooter>
    </jasperReport>
    pour plus d'information voila les différents versions:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    iReport3.4.7
    jasperreports-1.2.1.jar
    iText-2.1.7.jar
    commons-logging-api-1.0.2.jar
    commons-logging-1.0.2.jar
    commons-digester-1.7.jar
    commons-collections-2.1.jar
    commons-beanutils-1.5.jar
    groovy-all-1.5.5.jar
    Merci d'avance!!!!!

  2. #2
    Membre averti
    Inscrit en
    Novembre 2007
    Messages
    16
    Détails du profil
    Informations forums :
    Inscription : Novembre 2007
    Messages : 16
    Par défaut
    salut;
    lol c'est un problème de compatibilité , j'ai juste changer mon jasperreport-1.2.1 à jasperreport-3.5.3 pour être compatible avec mon iReport-3.7.4 .
    a+

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

Discussions similaires

  1. [Jasperreport] Générer Xls en java
    Par megtrinity dans le forum iReport
    Réponses: 1
    Dernier message: 10/04/2009, 10h18
  2. Réponses: 1
    Dernier message: 20/11/2008, 10h54
  3. module java qui appelle jasperReport avec passage de param
    Par mnemonic78 dans le forum iReport
    Réponses: 4
    Dernier message: 24/08/2007, 19h05
  4. [Java] Utilisation de JasperReport / iReport
    Par LeNeutrino dans le forum iReport
    Réponses: 5
    Dernier message: 03/10/2005, 17h28
  5. [Print]Edition en java : JTable ou JasperReports
    Par calimero82 dans le forum Composants
    Réponses: 5
    Dernier message: 05/11/2004, 15h50

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