Bonjour,
voila je tourne e rond depuis hier, mon exécution me renvoie pas mal d'erreurs, je cherche à débugger mais en vain !
j'ai deux classes :tation,Plots
leurs deux classes DAO :StationDAO,PlotDAO

une classe DataBaseOpenHelper herité par SQLiteOpenHelper

et une classe de test : StationActivity.java

Quand je lance l'application, l’exécution s’arrête, quand je consulte le logcat voici les messages d'erreurs que je reçois :
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
03-03 18:18:05.429 7440-7440/ppe4.velib E/SQLiteDatabase: Error inserting capaciteS=20 presenceborneS=non situationS=reparation etatCs=panne nomS=victoire
                                                          android.database.sqlite.SQLiteException: table station has no column named etatCs (code 1): , while compiling: INSERT INTO station(capaciteS,presenceborneS,situationS,etatCs,nomS) VALUES (?,?,?,?,?)
                                                          #################################################################
                                                          Error Code : 1 (SQLITE_ERROR)
                                                          Caused By : SQL(query) error or missing database.
                                                          	(table station has no column named etatCs (code 1): , while compiling: INSERT INTO station(capaciteS,presenceborneS,situationS,etatCs,nomS) VALUES (?,?,?,?,?))
                                                          #################################################################
                                                              at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                              at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1000)
                                                              at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:565)
                                                              at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                              at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
                                                              at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                              at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1633)
                                                              at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1505)
                                                              at ppe4.velib.Models.StationDAO.addStation(StationDAO.java:68)
                                                              at ppe4.velib.Activities.StationActivity.onCreate(StationActivity.java:28)
                                                              at android.app.Activity.performCreate(Activity.java:6904)
                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
                                                              at android.app.ActivityThread.access$1100(ActivityThread.java:229)
                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                              at android.os.Looper.loop(Looper.java:148)
                                                              at android.app.ActivityThread.main(ActivityThread.java:7331)
                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
03-03 18:18:05.439 7440-7440/ppe4.velib E/AndroidRuntime: FATAL EXCEPTION: main
                                                          Process: ppe4.velib, PID: 7440
                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{ppe4.velib/ppe4.velib.Activities.StationActivity}: android.database.sqlite.SQLiteException: no such column: etatCs (code 1): , while compiling: UPDATE station SET capaciteS=?,presenceborneS=?,situationS=?,etatCs=?,nomS=? WHERE numS = ?
                                                          #################################################################
                                                          Error Code : 1 (SQLITE_ERROR)
                                                          Caused By : SQL(query) error or missing database.
                                                          	(no such column: etatCs (code 1): , while compiling: UPDATE station SET capaciteS=?,presenceborneS=?,situationS=?,etatCs=?,nomS=? WHERE numS = ?)
                                                          #################################################################
                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3319)
                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
                                                              at android.app.ActivityThread.access$1100(ActivityThread.java:229)
                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
                                                              at android.os.Handler.dispatchMessage(Handler.java:102)
                                                              at android.os.Looper.loop(Looper.java:148)
                                                              at android.app.ActivityThread.main(ActivityThread.java:7331)
                                                              at java.lang.reflect.Method.invoke(Native Method)
                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
                                                           Caused by: android.database.sqlite.SQLiteException: no such column: etatCs (code 1): , while compiling: UPDATE station SET capaciteS=?,presenceborneS=?,situationS=?,etatCs=?,nomS=? WHERE numS = ?
                                                          #################################################################
                                                          Error Code : 1 (SQLITE_ERROR)
                                                          Caused By : SQL(query) error or missing database.
                                                          	(no such column: etatCs (code 1): , while compiling: UPDATE station SET capaciteS=?,presenceborneS=?,situationS=?,etatCs=?,nomS=? WHERE numS = ?)
                                                          #################################################################
                                                              at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                              at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1000)
                                                              at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:565)
                                                              at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                              at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59)
                                                              at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                              at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1738)
                                                              at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1686)
                                                              at ppe4.velib.Models.StationDAO.modifStation(StationDAO.java:85)
                                                              at ppe4.velib.Activities.StationActivity.onCreate(StationActivity.java:38)
                                                              at android.app.Activity.performCreate(Activity.java:6904)
                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
                                                              	... 9 more
en gros j'ai cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Caused By : SQL(query) error or missing database.
                                                          	(table station has no column named etatCs (code 1): , while compiling: INSERT INTO station(capaciteS,presenceborneS,situationS,etatCs,nomS) VALUES (?,?,?,?,?))
                                                          #################################################################


voici mon code :

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
 
databaseOpenHelper.java
package ppe4.velib.Models;
 
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
 
/**
 * Created by PC on 11/02/2017.
 */
public class DatabaseOpenHelper extends SQLiteOpenHelper {
 
    private static final String DATABASE_NAME = "db.sqlite";
    private static final int DATABASE_VERSION = 1;
    private static DatabaseOpenHelper sInstance;
 
    public static synchronized DatabaseOpenHelper getInstance(Context context) {
        if (sInstance == null) { sInstance = new DatabaseOpenHelper(context); }
        return sInstance;
    }
 
    private DatabaseOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }
 
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        // Création de la base de données
        // on exécute ici les requêtes de création des tables
        sqLiteDatabase.execSQL(StationDAO.STATION_TABLE_CREATE); // création table "station"
        sqLiteDatabase.execSQL(PlotDAO.PLOT_TABLE_CREATE); // création table "plot"
    }
 
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i2) {
        // Mise à jour de la base de données
        // méthode appelée sur incrémentation de DATABASE_VERSION
        // on peut faire ce qu'on veut ici, comme recréer la base :
        onCreate(sqLiteDatabase);
    }
 
 
}
stationDAO

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
package ppe4.velib.Models;
 
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import ppe4.velib.Metiers.Station;
 
 
 
    public class StationDAO {
 
 
    private static final String STATION_TABLE_NAME = "station";
 
    public static final String STATION_NUM = "numS";
    public static final String STATION_ETATCS = "etatCs";
    public static final String STATION_NOM = "nomS";                                      ////définir la façon dont la base de données sera ...
    public static final String STATION_SITUATION = "situationS";
    public static final String STATION_CAPACITE = "capaciteS";
    public static final String STATION_PRESENCEBORNE = "presenceborneS";
 
 
 
    public static final String STATION_TABLE_CREATE = "CREATE TABLE " + STATION_TABLE_NAME +
            " (" +
           " "+STATION_NUM + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
            " "+STATION_ETATCS + "TEXT," +                                            //implementation
            " "+STATION_NOM + " TEXT, " +
            " "+STATION_SITUATION + " TEXT, " +
            " "+STATION_CAPACITE + " INTEGER , " +
            " "+STATION_PRESENCEBORNE + " TEXT);";
 
 
 
    private DatabaseOpenHelper maBaseSQLite; // notre gestionnaire du fichier SQLite
        private SQLiteDatabase db;
 
        // Constructeur
        public StationDAO(Context context)
        {
            maBaseSQLite = DatabaseOpenHelper.getInstance(context);
        }
 
        public void open()
        {
            //on ouvre la table en lecture/écriture
            db = maBaseSQLite.getWritableDatabase();
        }
 
        public void close()
        {
            //on ferme l'accès à la BDD
            db.close();
        }
 
        public long addStation(Station station) {
            // Ajout d'un enregistrement dans la table
 
            ContentValues values = new ContentValues();
            values.put(STATION_ETATCS, station.getEtatCS());
            values.put(STATION_NOM, station.getNomS());
            values.put(STATION_SITUATION, station.getSituation());
            values.put(STATION_CAPACITE, station.getCapacite());
            values.put(STATION_PRESENCEBORNE, station.getPresenceBorne());
 
            // insert() retourne l'id du nouvel enregistrement inséré, ou -1 en cas d'erreur
            return db.insert(STATION_TABLE_NAME,null,values);
        }
 
        public int modifStation(Station station) {
            // modification d'un enregistrement
            // valeur de retour : (int) nombre de lignes affectées par la requête
 
            ContentValues values = new ContentValues();
            values.put(STATION_ETATCS, station.getEtatCS());
            values.put(STATION_NOM, station.getNomS());
            values.put(STATION_SITUATION, station.getSituation());
            values.put(STATION_CAPACITE, station.getCapacite());
            values.put(STATION_PRESENCEBORNE, station.getPresenceBorne());
 
            String where = STATION_NUM+" = ?";
            String[] whereArgs = {station.getNumS()+""};
 
            return db.update(STATION_TABLE_NAME, values, where, whereArgs);
        }
 
        public int supStation(Station station) {
            // suppression d'un enregistrement
            // valeur de retour : (int) nombre de lignes affectées par la clause WHERE, 0 sinon
 
            String where = STATION_NUM+" = ?";
            String[] whereArgs = {station.getNumS()+""};
 
            return db.delete(STATION_TABLE_NAME, where, whereArgs);
        }
 
        public Station getStationParNum(int numS) {
            // Retourne la station dont le num est passé en paramètre
 
            Station s =new Station(0, "", "", "",0 , "");
 
            Cursor c = db.rawQuery("SELECT * FROM "+STATION_TABLE_NAME+" WHERE "+STATION_NUM+"="+numS, null);
            if (c.moveToFirst()) {
                s.setNumS(c.getInt(c.getColumnIndex(STATION_NUM)));
                s.setEtatCS(c.getString(c.getColumnIndex(STATION_ETATCS)));
                s.setNomS(c.getString(c.getColumnIndex(STATION_NOM)));
                s.setSituation(c.getString(c.getColumnIndex(STATION_SITUATION)));
                s.setCapacite(c.getInt(c.getColumnIndex(STATION_CAPACITE)));
                s.setPresenceBorne(c.getString(c.getColumnIndex(STATION_PRESENCEBORNE)));
                c.close();
            }
 
            return s;
        }
 
        public Cursor getStations() {
            // sélection de tous les enregistrements de la table
            return db.rawQuery("SELECT * FROM "+STATION_TABLE_NAME, null);
        }
 
 
 
    }
[CODE]stationActivity pour tester:

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
package ppe4.velib.Activities;
 
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;
 
 
import ppe4.velib.Metiers.Station;
import ppe4.velib.Models.StationDAO;
import ppe4.velib.R;
 
/**
 * Created by PC on 16/02/2017.
 */
public class StationActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.station_display);
 
 
        StationDAO s = new StationDAO(this); // gestionnaire de la table "animal"
        s.open(); // ouverture de la table en lecture/écriture
 
// insertion. L'id sera attribué automatiquement par incrément
//        s.addStation(new Station(0,"courant","Quinconce","Fonctionne",15,"oui"));
        s.addStation(new Station(1,"panne","victoire","reparation",20,"non"));
 
// modification du nom de la station dont l'id est 1
        Station station= s.getStationParNum(1);
        station.setEtatCS("panneset");
        station.setNomS("stGenes");
        station.setSituation("fonctionneModif");
        station.setCapacite(12);
        station.setPresenceBorne("Non");
 
        s.modifStation(station);
// suppression
        s.supStation(station);
 
// Listing des enregistrements de la table
        Cursor c = s.getStations();
        if (c.moveToFirst())
        {
            do {
                Log.d("test",
                        c.getInt(c.getColumnIndex(StationDAO.STATION_NUM)) + "," +
                                c.getString(c.getColumnIndex(StationDAO.STATION_NOM))
                );
            }
            while (c.moveToNext());
        }
        c.close(); // fermeture du curseur
 
// fermeture du gestionnaire
        s.close();
 
 
 
    }
 
 
}
le mssg d'erreur m'envoir ca
Code : Sélectionner tout - Visualiser dans une fenêtre à part
table station has no column named etatCs (code 1): , while compiling: INSERT INTO station
alors que je l'ai bien declaré !

voyez vous ou je me suis planté , vous ?

merci svp!