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 :

JTable et connexion avec BD Access


Sujet :

JDBC Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Mai 2015
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Mai 2015
    Messages : 26
    Par défaut JTable et connexion avec BD Access
    Bonsoir,
    je travail sur Jtable en connexion avec BD Access j'ai écrit le code suivant:
    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
       try {
                 SimpleDateFormat simple= new SimpleDateFormat("dd/MM/yyyy");
               Date d1 ,d2 ;
                String dateD = JOptionPane.showInputDialog(null, "Veuillez entrer la date début (mm/jj/aaaa) !", "Date début!",JOptionPane.QUESTION_MESSAGE);
                if(!dateD.isEmpty()){
                    String dateF = JOptionPane.showInputDialog(null, "Veuillez entrer la date fin (mm/jj/aaaa) !", "Date fin!",JOptionPane.QUESTION_MESSAGE);
                    if(!dateF.isEmpty()){
     
                           d1 = simple.parse(dateD);
                           d2=simple.parse(dateF);
     
                        connect con=new connect();
     System.out.println(dateD); System.out.println(dateF);
                        Statement stm=con.getStatement();
                        ResultSet resultc;
                        String[] titres = {"N°FACTURE","Date Facture","VALEUR DEV","FRNS","N°DOSSIER","observation","Categorier","Palette","Nombre de colis","Poids Brut","Poids Net","Montant"};
     
                            resultc = stm.executeQuery("SELECT Count(DETAIL_FACTURE_IMPORT.[N° FACTURE]) FROM FACTURE_IMPORT INNER JOIN DETAIL_FACTURE_IMPORT ON FACTURE_IMPORT.[N°FACTURE] = DETAIL_FACTURE_IMPORT.[N° FACTURE] WHERE (((FACTURE_IMPORT.[DTE FACTURE]) Between #"+simple.format(d1)+"# And #"+simple.format(d2)+"#));");
                            resultc.next();
                            int i=resultc.getInt(1);
                            System.out.println(i);
                            Object[][] data= new Object[i][12] ;
                            String Sql= "SELECT FACTURE_IMPORT.[N°FACTURE], FACTURE_IMPORT.[DTE FACTURE], FACTURE_IMPORT.[VALEUR DEV], FACTURE_IMPORT.FRNS, FACTURE_IMPORT.[N°DOSSIER], FACTURE_IMPORT.observation, DETAIL_FACTURE_IMPORT.CATEGORIE, DETAIL_FACTURE_IMPORT.Palette, DETAIL_FACTURE_IMPORT.Colis, DETAIL_FACTURE_IMPORT.[Poids Brut], DETAIL_FACTURE_IMPORT.[Poids Net], DETAIL_FACTURE_IMPORT.Montant " +
    "FROM FACTURE_IMPORT INNER JOIN DETAIL_FACTURE_IMPORT ON FACTURE_IMPORT.[N°FACTURE] = DETAIL_FACTURE_IMPORT.[N° FACTURE] WHERE (((FACTURE_IMPORT.[DTE FACTURE]) Between #"+simple.format(d1)+"# And #"+simple.format(d2)+"#));";
                            ResultSet res=stm.executeQuery(Sql);
                            int j=0;
                            while(res.next()) {
     
                                data[j][0] = res.getString(1);
                                data[j][1] = res.getDate(2);
                                data[j][2] = res.getFloat(3);
                                data[j][3] = res.getString(4);
                                data[j][4] = res.getString(5);
                                data[j][5] = res.getString(6);
                                data[j][6] = res.getString(7);                            
                                data[j][7] = res.getInt(8);
                                data[j][8] = res.getInt(9);
                                data[j][9] = res.getFloat(10);
                                data[j][10] = res.getFloat(11);
                                data[j][11] = res.getFloat(12);
     
                                j++;
                            }
                            JTable table=new JTable(data,titres);
                            table.setPreferredScrollableViewportSize(new Dimension(1990, 990));
                            table.setFillsViewportHeight(true);
     
                            JScrollPane scroll=new JScrollPane(table);
                            JFrame f=new JFrame("Toutes les Factures Import");
                            f.add(scroll);
                            f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                            f.setSize(2000,1000);
                            f.setVisible(true);
     
     
                    }}
     
                }catch(Exception ex){System.err.println(ex.getMessage());}
        }
    mais j'ai eu l'erreur suivante: [Microsoft][Pilote ODBC Microsoft Access] Trop peu de param?tres. 2 attendu.

    merci pour votre aide.

  2. #2
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Mai 2015
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Mai 2015
    Messages : 26
    Par défaut
    il n'y a personne qui peut m'aider je suis bloquée ??

  3. #3
    Membre Expert Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Par défaut
    salut,
    peux-tu nous donner l´erreur complète?

    Eric

  4. #4
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Ainsi que parmis tes requêtes SQL laquelle génère cette erreur?

  5. #5
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Mai 2015
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Mai 2015
    Messages : 26
    Par défaut
    bonjour, voila toute l'erreur:
    java.sql.SQLException: [Microsoft][Pilote ODBC Microsoft Access] Trop peu de param?tres. 2 attendu.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(Unknown Source)
    at pkgimport.export.ToutesFactures.FactImpActionPerformed(ToutesFactures.java:402)
    at pkgimport.export.ToutesFactures.access$000(ToutesFactures.java:28)
    at pkgimport.export.ToutesFactures$1.actionPerformed(ToutesFactures.java:67)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$300(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    [Microsoft][Pilote ODBC Microsoft Access] Trop peu de param?tres. 2 attendu.

  6. #6
    Membre averti
    Femme Profil pro
    Développeur Java
    Inscrit en
    Mai 2015
    Messages
    26
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Mai 2015
    Messages : 26
    Par défaut
    et c'est dans cette ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     resultc = stm.executeQuery("SELECT Count(DETAIL_FACTURE_IMPORT.[N° FACTURE]) FROM FACTURE_IMPORT INNER JOIN DETAIL_FACTURE_IMPORT ON FACTURE_IMPORT.[N°FACTURE] = DETAIL_FACTURE_IMPORT.[N° FACTURE] ;");

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

Discussions similaires

  1. Réponses: 1
    Dernier message: 13/01/2010, 10h18
  2. Pb de formview en connexion avec Access
    Par patbeautifulday1 dans le forum ASP.NET
    Réponses: 10
    Dernier message: 20/07/2007, 16h51
  3. problème de connexion avec la db en SQL et en access
    Par thierry007 dans le forum Accès aux données
    Réponses: 9
    Dernier message: 28/12/2006, 13h39
  4. [VB6]Problème connexion avec une base ACCESS
    Par mcay dans le forum VB 6 et antérieur
    Réponses: 8
    Dernier message: 15/05/2006, 17h47
  5. Réponses: 1
    Dernier message: 06/04/2006, 15h35

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