I am attempting to create an SQLite database, but it is giving me an error I will post code below.
public class DBHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "waiters.db";
public static final String TABLE_WAITERINFO = "waiterinfo";
public static final String COLUMN_KEY = "key";
public static final String COLUMN_NAME = "name";
public DBHandler(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, DATABASE_NAME, factory, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String query = "CREATE TABLE " + TABLE_WAITERINFO + "(" +
COLUMN_KEY + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_NAME + " TEXT, " +
");";
db.execSQL(query);
}
this is the code which is giving the error.
Caused by: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TABLE waiterinfo(key INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, );
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.executeSql(SQLiteDatabase.java:1674)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1605)
at com.example.drooler1.assignment_17680817.DBHandler.onCreate(DBHandler.java:25)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.drooler1.assignment_17680817.DBHandler.addWaiter(DBHandler.java:38)
at com.example.drooler1.assignment_17680817.AdminActivity.addWaiter(AdminActivity.java:30)
at java.lang.reflect.Method.invoke(Native Method)
This is the error
Aucun commentaire:
Enregistrer un commentaire