samedi 13 février 2016

SQLiteException: near "XY": syntax error (code 1):

I wanna try some Sqlite request on android app,

My request is here :

private static final String CREATE_BDD_SMS_RECEIVED = "CREATE TABLE " + TABLE_SMS_RECEIVED + " ("
        + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + COL_DateReceiving + " TEXT, "
        + COL_PROCESSED + " TEXT, " + COL_PHONE + "TEXT, " + COL_DATA + "TEXT)"; 

And my OnCreate of myBaseSqlite class is here :

@Override
public void onCreate(SQLiteDatabase db) {
    //on créé la table à partir de la requête écrite dans la variable CREATE_BDD sent et received
    db.execSQL(CREATE_BDD_SMS_RECEIVED);
}

And then on my MainActivity :

CSmsReceiverDAO cSmsReceiverDAO = new CSmsReceiverDAO(this);
CSmsReceived SmsReceived1 = new CSmsReceived.SmsReceivedBuilder()
        .Data("coords XY").DateReceiving("janvier").Phone("+33565456").Processed("zz").build();
cSmsReceiverDAO.open();
try {
    cSmsReceiverDAO.persist(SmsReceived1);
} catch (Exception e) {
    e.printStackTrace();
}

But i have an error when executing :

02-13 22:56:14.648 2491-2491/com.dev.boblinux.cador E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
02-13 22:56:14.648 2491-2491/com.dev.boblinux.cador E/GMPM: Scheduler not set. Not logging error/warn.
02-13 22:56:14.672 2491-2506/com.dev.boblinux.cador E/GMPM: Uploading is not possible. App measurement disabled
02-13 22:56:14.717 2491-2491/com.dev.boblinux.cador E/SQLiteLog: (1) near "XY": syntax error
02-13 22:56:14.729 2491-2491/com.dev.boblinux.cador E/SQLiteDatabase: Error inserting coords XY=coords XY +33565456=+33565456 zz=zz janvier=janvier
                                                                      android.database.sqlite.SQLiteException: near "XY": syntax error (code 1): , while compiling: INSERT INTO table_sms_received(coords XY,+33565456,zz,janvier) VALUES (?,?,?,?)
                                                                          at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                                                                          at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
                                                                          at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
                                                                          at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
                                                                          at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
                                                                          at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
                                                                          at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469)
                                                                          at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341)
                                                                          at com.dev.boblinux.cador.bdd.CSmsReceiverDAO.persist(CSmsReceiverDAO.java:62)
                                                                          at com.dev.boblinux.cador.activities.CMainActivity.onCreate(CMainActivity.java:40)
                                                                          at android.app.Activity.performCreate(Activity.java:6237)
                                                                          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                          at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                          at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                          at android.os.Looper.loop(Looper.java:148)
                                                                          at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                          at java.lang.reflect.Method.invoke(Native Method)
                                                                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

I believe the interesting error line is here :

E/SQLiteDatabase: Error inserting coords XY=coords XY +33565456=+33565456 zz=zz janvier=janvier    



android.database.sqlite.SQLiteException: near "XY": syntax error (code 1): , 
while compiling: INSERT INTO table_sms_received(coords XY,+33565456,zz,janvier) VALUES (?,?,?,?)

But i don't see where is the error syntaxe..

Thanks for helping me ;)

Aucun commentaire:

Enregistrer un commentaire