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 :

Erreur ODBC => SQL serveur: nom d'objet incorrect


Sujet :

JDBC Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Mars 2007
    Messages
    5
    Détails du profil
    Informations forums :
    Inscription : Mars 2007
    Messages : 5
    Points : 7
    Points
    7
    Par défaut Erreur ODBC => SQL serveur: nom d'objet incorrect
    Salut
    J'ai crée une classe connexiondb, une classe filiale et un formulaire JFfiliale
    et aprés avoir entrer des infos dans le JFfiliale à execution il me retourne l'erreur suivante:erreur lors connection db(java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL server]'filiale' :nom d'objet incorrect.)

    voici le code de la classe filiale

    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
    /*
     * filiale.java
     *
     * Created on 3 mars 2007, 13:08
     *
     * To change this template, choose Tools | Template Manager
     * and open the template in the editor.
     */
     
    /**
     *
     * @author Lyly
     */
    public class filiale {
        private String codfil;
        private String denofil;
        private String phonefil;
        /** Creates a new instance of filiale */
        //constructeur 1
       //filiale fil=new filiale();
         public filiale() {
            this.codfil="null";
            this.denofil="null";
            this.phonefil="null"; 
        }
        //constructeur 2
        public filiale(String cf,String df,String phf) {
            initialisation(cf,df,phf);
        }
        public void initialisation(String cf,String df,String phf){
            this.codfil=cf;
            this.denofil=df;
            this.phonefil=phf;
        }
        public String getcodfil(){
            return codfil;
        }
        public String getdenofil(){
            return denofil;
        }
        public String getphonefil(){
            return phonefil; 
        }
        public void setcodfil(String cf){
            this.codfil=cf;
        }
        public void setdenofil(String df){
            this.denofil=df;
        } 
        public void setphonefil(String phf){
            this.phonefil=phf;
        }
    }
    voici le code de la classe connexion


    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
    /*
     *
     */
    import java.net.*;
    import java.util.*;
    import java.sql.*;
    public class connectiondb{ 
     
    	Connection conn = null; 
            Statement S=null;
            ResultSet RS=null;
     public connectiondb(String cf,String df,String phf)
     {cf=null;df=null;phf=null;};   
     public void connectiondb() throws ClassNotFoundException{
     
             String strClassName = "sun.jdbc.odbc.JdbcOdbcDriver";
             String strUrl = "jdbc:odbc:BD_Incidents";
             Class.forName(strClassName);
              String username="sa";
              String password="sa";
     
              //username=nom utilisateur
               //password=mot de passe
                   try {
             conn = DriverManager.getConnection(strUrl,"",""); 
          }
           catch(Exception  e){
             //System.err.println("Driver non chargé !");
             e.printStackTrace();  
           }
       }
     public void insertion_filiale(String cf, String df, String phf){
         try{	 String sql="insert into filiale values('"+cf+" ','"+df+"','"+phf+"')";
                     int Ligne;
                     S=conn.createStatement();
                     Ligne=S.executeUpdate(sql);
        	}catch(Exception e){
    		System.out.println("erreur lors connection bd("+e+")");
    	}
     
     }
     public void selection_filiale(String cf, String df, String phf){
         try{	 
                     String sql="select * from filiale";
                     S=conn.createStatement();
                     RS=S.executeQuery(sql);
                     int nlig=RS.getMetaData().getColumnCount();
                     while(RS.next()){
                         cf=RS.getString(1);
                         df=RS.getString(2);
                         phf=RS.getString(3);
                     }
        	}catch(Exception e){
    		//System.out.println("erreur lors connection bd("+e+")");
    	}
     
     }
     public void deconnectiondb(){
       try{
        conn.close();
       }catch(Exception e) {
            // System.err.println("Deconnection non effectué");
             e.printStackTrace();
           }
    }
     
     
     
     
    }
    voici le code du formulaire JFfiliale


    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
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    import java.sql.*;
    import javax.swing.JOptionPane;
    /*
     * JFfiliale.java
     *
     * Created on 3 mars 2007, 14:50
     */
     
    /**
     *
     * @author  Lyly*/
    import ges_inci.*;
    import java.net.*;
    import java.util.*;
    import java.sql.*;
    import java.lang.*;
     
    public class JFfiliale extends javax.swing.JFrame {
     
        /**
         * Creates new form JFfiliale
         */
        public JFfiliale() {
            initComponents();
        }
        String cf;
        String df;
        String phf;
        String valeur;
        connection connectiondb;
        //filiale fil=new filiale(cf,df,phf);
     
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jtfcodfil = new javax.swing.JTextField();
            jLabel3 = new javax.swing.JLabel();
            jtfdenofil = new javax.swing.JTextField();
            jLabel4 = new javax.swing.JLabel();
            jtfphonefil = new javax.swing.JTextField();
            jBvalider = new javax.swing.JButton();
            jBannuler = new javax.swing.JButton();
            jBfermer = new javax.swing.JButton();
     
            org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            );
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            );
     
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("FORMULAIRE  SAISIE  FILIALES");
            setBackground(new java.awt.Color(102, 204, 255));
            setName("CREATION DES FILIALES");
            addComponentListener(new java.awt.event.ComponentAdapter() {
                public void componentMoved(java.awt.event.ComponentEvent evt) {
                    formComponentMoved(evt);
                }
                public void componentResized(java.awt.event.ComponentEvent evt) {
                    formComponentResized(evt);
                }
                public void componentShown(java.awt.event.ComponentEvent evt) {
                    formComponentShown(evt);
                }
            });
     
            jLabel1.setBackground(new java.awt.Color(204, 204, 204));
            jLabel1.setFont(new java.awt.Font("Verdana", 1, 16));
            jLabel1.setText(" FILIALES");
            jLabel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));
     
            jLabel2.setFont(new java.awt.Font("Verdana", 0, 12));
            jLabel2.setText("CodFil :");
     
            jtfcodfil.setName("Tcodfil");
     
            jLabel3.setFont(new java.awt.Font("Verdana", 0, 12));
            jLabel3.setText("DenoFil :");
     
            jtfdenofil.setName("TFdenofil");
     
            jLabel4.setFont(new java.awt.Font("Verdana", 0, 12));
            jLabel4.setText("PhoneFil :");
     
            jtfphonefil.setName("TFphonefil");
     
            jBvalider.setFont(new java.awt.Font("Verdana", 0, 12));
            jBvalider.setText("Enregistrer");
            jBvalider.setName("BTenregistrer\n\n\n");
            jBvalider.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jBvaliderActionPerformed(evt);
                }
            });
     
            jBannuler.setFont(new java.awt.Font("Verdana", 0, 12));
            jBannuler.setText("Annuler");
            jBannuler.setName("BTannuler");
            jBannuler.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jBannulerActionPerformed(evt);
                }
            });
     
            jBfermer.setFont(new java.awt.Font("Verdana", 0, 12));
            jBfermer.setText("Quitter");
            jBfermer.setName("BTquitter");
            jBfermer.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jBfermerActionPerformed(evt);
                }
            });
     
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .add(83, 83, 83)
                            .add(jBvalider)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jBannuler)
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(jBfermer))
                        .add(layout.createSequentialGroup()
                            .add(20, 20, 20)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jLabel2)
                                .add(jLabel3)
                                .add(jLabel4))
                            .add(27, 27, 27)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                .add(jtfphonefil)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, jtfdenofil)
                                .add(org.jdesktop.layout.GroupLayout.LEADING, jtfcodfil, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)))
                        .add(layout.createSequentialGroup()
                            .add(142, 142, 142)
                            .add(jLabel1)))
                    .addContainerGap(44, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(layout.createSequentialGroup()
                    .addContainerGap()
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 31, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(19, 19, 19)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jLabel2)
                        .add(jtfcodfil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(27, 27, 27)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel3)
                        .add(jtfdenofil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(21, 21, 21)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel4)
                        .add(jtfphonefil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(36, 36, 36)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jBvalider)
                        .add(jBannuler)
                        .add(jBfermer))
                    .addContainerGap(73, Short.MAX_VALUE))
            );
            pack();
        }// </editor-fold>//GEN-END:initComponents
     
        private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
    // TODO add your handling code here:
        }//GEN-LAST:event_formComponentResized
     
        private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved
    // TODO add your handling code here:
        }//GEN-LAST:event_formComponentMoved
     
        private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
    // TODO add your handling code here:
     
        }//GEN-LAST:event_formComponentShown
        private void jBfermerActionPerformed(java.awt.event.ActionEvent evt){
           System.exit(0);
       }
         private void jBannulerActionPerformed(java.awt.event.ActionEvent evt){
           jtfcodfil.setText("");
           jtfdenofil.setText("");
           jtfphonefil.setText("");
       }
        private void jBvaliderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBvaliderActionPerformed
    // TODO add your handling code here:
         cf=jtfcodfil.getText();
         df=jtfdenofil.getText();
         phf=jtfphonefil.getText();
         //instancie la classe filiale
         filiale f=new filiale(cf,df,phf);
         //modifie les les valeur des attribut de la classe filiale 
         //initialiser a null o depart dans la classe filiale
         f.setcodfil(cf);
         f.setdenofil(df);
         f.setphonefil(phf);
         connectiondb con=new connectiondb(cf,df,df);
            try {
                con.connectiondb();
                con.insertion_filiale(cf,df,phf);
                con.selection_filiale(cf,df,phf);
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            }
         con.insertion_filiale(cf,df,phf);
         con.selection_filiale(cf,df,phf);
     
         //valeur="     jtfcodfil="+f.getcodfil()+"        jtfdenofil="+f.getdenofil()+"        jtfphonefil="+f.getphonefil();
        // JOptionPane.showMessageDialog(this,valeur,"element saisis",JOptionPane.INFORMATION_MESSAGE);
        }//GEN-LAST:event_jBvaliderActionPerformed
     
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new JFfiliale().setVisible(true);
                                }
            });
     
        }
     
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JButton jBannuler;
        private javax.swing.JButton jBfermer;
        private javax.swing.JButton jBvalider;
        private javax.swing.JDialog jDialog1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JLabel jLabel4;
        private javax.swing.JTextField jtfcodfil;
        private javax.swing.JTextField jtfdenofil;
        private javax.swing.JTextField jtfphonefil;
        // End of variables declaration//GEN-END:variables
     
    }

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    949
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Octobre 2005
    Messages : 949
    Points : 1 856
    Points
    1 856
    Par défaut
    Ouille! Trop de code! Et sans utiliser la mise en forme de code (bouton #)!

    Et pourtant je vais en réclamer d'avantage : le script de création de la table dans la base de données.

Discussions similaires

  1. erreur à l'installation sql serveur 2005
    Par phbres dans le forum MS SQL Server
    Réponses: 1
    Dernier message: 29/05/2009, 18h32
  2. Erreur lors d'un update d'une table sql serveur en liaison ODBC avec SAS
    Par wizou44 dans le forum Administration et Installation
    Réponses: 5
    Dernier message: 25/05/2009, 09h44
  3. Erreur ODBC SQL serveur 2000
    Par snach dans le forum Développement
    Réponses: 0
    Dernier message: 06/04/2009, 15h58
  4. Erreur d'installation SQL SERVEUR
    Par JPCOCU dans le forum MS SQL Server
    Réponses: 5
    Dernier message: 11/01/2006, 17h08
  5. Erreur de connexion au serveur SQL 3
    Par NeHuS dans le forum Langage SQL
    Réponses: 3
    Dernier message: 28/01/2005, 13h55

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