我已经设置了服务器,目前停留在我的 android 代码中。
谁能帮我分享一下灯?
这是databasehandler
我的课android application
。
package net.ddns.manajemenpekerjaan.manajemenpekerjaan;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import org.jumpmind.symmetric.android.SQLiteOpenHelperRegistry;
import org.jumpmind.symmetric.android.SymmetricService;
import java.sql.Blob;
import java.util.Properties;
/**
* Created by Wuller on 12/25/2015.
*/
public class DatabaseOperation extends SQLiteOpenHelper {
public static final int DATABASE_VERSION = 1;
private DatabaseOperation mOpenHelper;
public final Context getContext() {
return getContext();
}
public String CREATE_QUERY_TABEL_USER = "CREATE TABLE " +
DataTabel.TableInfo.NAMA_TABEL_USER + "("
+ DataTabel.TableInfo.KOLOM_NIP_USER + " TEXT PRIMARY KEY,"
+ DataTabel.TableInfo.KOLOM_PASSWORD_USER + " TEXT,"
+ DataTabel.TableInfo.KOLOM_NAMA_USER + " TEXT,"
+ DataTabel.TableInfo.KOLOM_KODE_JABATAN_USER + " INTEGER"
+ ")";
public String CREATE_QUERY_TABEL_TUGAS = "CREATE TABLE " +
DataTabel.TableInfo.NAMA_TABEL_TUGAS + "("
+ DataTabel.TableInfo.KOLOM_ID_TUGAS + " INTEGER PRIMARY KEY,"
+ DataTabel.TableInfo.KOLOM_PASSWORD_USER + " TEXT,"
+ DataTabel.TableInfo.KOLOM_VERSI_TUGAS + " DATETIME,"
+ DataTabel.TableInfo.KOLOM_NIP_ATASAN + " TEXT,"
+ DataTabel.TableInfo.KOLOM_NIP_BAWAHAN + " TEXT,"
+ DataTabel.TableInfo.KOLOM_DESKRIPSI_TUGAS + " TEXT,"
+ DataTabel.TableInfo.KOLOM_TARGET_TUGAS + " DATE,"
+ DataTabel.TableInfo.KOLOM_INISIATIF_TUGAS + " TEXT,"
+ DataTabel.TableInfo.KOLOM_NOMOR_DISPOSISI + " TEXT,"
+ DataTabel.TableInfo.KOLOM_LAMPIRAN_BUKTI + " BLOB,"
+ DataTabel.TableInfo.KOLOM_STATUS_TUGAS + " TEXT"
+ ")";
public String CREATE_QUERY_TABEL_VERSI_TUGAS = "CREATE TABLE " +
DataTabel.TableInfo.NAMA_TABEL_VERSI_TUGAS + "("
+ DataTabel.TableInfo.KOLOM_ID_VERSI + " INTEGER PRIMARY KEY,"
+ DataTabel.TableInfo.KOLOM_VERSI_TANGGAL + " DATETIME,"
+ DataTabel.TableInfo.KOLOM_ID_TUGAS_VERSITUGAS + " INTEGER,"
+ DataTabel.TableInfo.KOLOM_STATUS_TUGAS_VERSITUGAS + " INTEGER"
+ ")";
public String CREATE_QUERY_TABEL_ATASAN_BAWAHAN = "CREATE TABLE " +
DataTabel.TableInfo.NAMA_TABEL_ATASAN_BAWAHAN + "("
+ DataTabel.TableInfo.KOLOM_NIP_ATASAN_ATASANBAWAHAN + " TEXT,"
+ DataTabel.TableInfo.KOLOM_NIP_BAWAHAN_ATASANBAWAHAN + " TEXT,"
+ DataTabel.TableInfo.KOLOM_VERSI_ATASANBAWAHAN + " DATETIME"
+ ")";
public DatabaseOperation(Context context) {
super(context, DataTabel.TableInfo.DATABASE_NAME, null, DATABASE_VERSION);
Log.d("Database operations", "Database created");
}
@Override
public void onCreate(SQLiteDatabase sdb) {
/////SETTING SYMMETRIC
final String HELPER_KEY = "ManajemenPekerjaanHelperKey";
//mOpenHelper = new DatabaseOperation(getContext());
mOpenHelper = new DatabaseOperation(getContext());
// Register the database helper, so it can be shared with the SymmetricService
SQLiteOpenHelperRegistry.register(HELPER_KEY, mOpenHelper);
Intent intent = new Intent(getContext(), SymmetricService.class);
// Notify the service of the database helper key
intent.putExtra(SymmetricService.INTENTKEY_SQLITEOPENHELPER_REGISTRY_KEY,
HELPER_KEY);
intent.putExtra(SymmetricService.INTENTKEY_REGISTRATION_URL,
"http://manajemenpekerjaan.ddns.net:31415/sync/server");
intent.putExtra(SymmetricService.INTENTKEY_EXTERNAL_ID,
"android");
intent.putExtra(SymmetricService.INTENTKEY_NODE_GROUP_ID, "client");
intent.putExtra(SymmetricService.INTENTKEY_START_IN_BACKGROUND,
true);
Properties properties = new Properties();
intent.putExtra(SymmetricService.INTENTKEY_PROPERTIES, properties);
getContext().startService(intent);
return;
//SETTING SYMMETRIC
sdb.execSQL(CREATE_QUERY_TABEL_USER);
sdb.execSQL(CREATE_QUERY_TABEL_TUGAS);
sdb.execSQL(CREATE_QUERY_TABEL_VERSI_TUGAS);
sdb.execSQL(CREATE_QUERY_TABEL_ATASAN_BAWAHAN);
Log.d("Database operations", "Table created");
}
@Override
public void onUpgrade(SQLiteDatabase sdb, int oldVersion, int newVersion) {
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_USER);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_TUGAS);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_VERSI_TUGAS);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_ATASAN_BAWAHAN);
onCreate(sdb);
}
public void InputData(DatabaseOperation mOpenHelper, String nipatasan, String nipbawahan, String deskripsitugas, String targettugas, String nomordisposisi, Blob lampiranbukti, String statustugas) {
SQLiteDatabase SQ = mOpenHelper.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(DataTabel.TableInfo.KOLOM_NIP_ATASAN, nipatasan);
cv.put(DataTabel.TableInfo.KOLOM_NIP_BAWAHAN, nipbawahan);
cv.put(DataTabel.TableInfo.KOLOM_DESKRIPSI_TUGAS, deskripsitugas);
cv.put(DataTabel.TableInfo.KOLOM_TARGET_TUGAS, String.valueOf(targettugas));
cv.put(DataTabel.TableInfo.KOLOM_NOMOR_DISPOSISI, nomordisposisi);
cv.put(DataTabel.TableInfo.KOLOM_LAMPIRAN_BUKTI, String.valueOf(lampiranbukti));
cv.put(DataTabel.TableInfo.KOLOM_STATUS_TUGAS, statustugas);
long k = SQ.insert(DataTabel.TableInfo.NAMA_TABEL_TUGAS, null, cv);
Log.d("Database operations", "Tugas baru berhasil disimpan");
}
public Cursor AmbilDataTugas(DatabaseOperation mOpenHelper) {
SQLiteDatabase SQ = mOpenHelper.getReadableDatabase();
String[] kolom = {DataTabel.TableInfo.KOLOM_NIP_BAWAHAN, DataTabel.TableInfo.KOLOM_DESKRIPSI_TUGAS, DataTabel.TableInfo.KOLOM_TARGET_TUGAS, DataTabel.TableInfo.KOLOM_INISIATIF_TUGAS, DataTabel.TableInfo.KOLOM_STATUS_TUGAS};
Cursor kursor = SQ.query(DataTabel.TableInfo.NAMA_TABEL_TUGAS, kolom, null, null, null, null, null);
return kursor;
}
public Cursor AmbilDataLogin(DatabaseOperation mOpenHelper) {
SQLiteDatabase SQ = mOpenHelper.getReadableDatabase();
String[] kolom = {DataTabel.TableInfo.KOLOM_NIP_USER, DataTabel.TableInfo.KOLOM_PASSWORD_USER};
Cursor kursor = SQ.query(DataTabel.TableInfo.NAMA_TABEL_USER, kolom, null, null, null, null, null, null);
return kursor;
}
}
我使用 android studio 发现的错误是
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_USER);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_TUGAS);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_VERSI_TUGAS);
sdb.execSQL("DROP TABLE IF EXIST " + DataTabel.TableInfo.NAMA_TABEL_ATASAN_BAWAHAN);
这么说UNREACABLE STATEMENT
。