use of android.database.SQLException in project androrm by androrm.
the class DataField method exec.
protected boolean exec(Context context, Class<? extends Model> model, String sql) {
DatabaseAdapter adapter = DatabaseAdapter.getInstance(context);
adapter.open();
try {
adapter.exec(sql);
} catch (SQLException e) {
adapter.close();
return false;
}
adapter.close();
return true;
}
use of android.database.SQLException in project sqlbrite by square.
the class BriteDatabaseTest method executeInsertThrowsAndDoesNotTrigger.
@Test
public void executeInsertThrowsAndDoesNotTrigger() {
SQLiteStatement statement = real.compileStatement("INSERT INTO " + TABLE_EMPLOYEE + " (" + TestDb.EmployeeTable.NAME + ", " + TestDb.EmployeeTable.USERNAME + ") " + "VALUES ('Alice Allison', 'alice')");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).skip(// Skip initial
1).subscribe(o);
try {
db.executeInsert(TABLE_EMPLOYEE, statement);
fail();
} catch (SQLException ignored) {
}
o.assertNoMoreEvents();
}
use of android.database.SQLException in project sqlbrite by square.
the class BriteDatabaseTest method executeUpdateDeleteThrowsAndDoesNotTrigger.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SdkSuppress(minSdkVersion = Build.VERSION_CODES.HONEYCOMB)
@Test
public void executeUpdateDeleteThrowsAndDoesNotTrigger() {
SQLiteStatement statement = real.compileStatement("UPDATE " + TABLE_EMPLOYEE + " SET " + TestDb.EmployeeTable.USERNAME + " = 'alice'");
db.createQuery(TABLE_EMPLOYEE, SELECT_EMPLOYEES).skip(// Skip initial
1).subscribe(o);
try {
db.executeUpdateDelete(TABLE_EMPLOYEE, statement);
fail();
} catch (SQLException ignored) {
}
o.assertNoMoreEvents();
}
use of android.database.SQLException in project 9GAG by stormzhang.
the class DataProvider method insert.
@Override
public Uri insert(Uri uri, ContentValues values) {
synchronized (DBLock) {
String table = matchTable(uri);
SQLiteDatabase db = getDBHelper().getWritableDatabase();
long rowId = 0;
db.beginTransaction();
try {
rowId = db.insert(table, null, values);
db.setTransactionSuccessful();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
} finally {
db.endTransaction();
}
if (rowId > 0) {
Uri returnUri = ContentUris.withAppendedId(uri, rowId);
getContext().getContentResolver().notifyChange(uri, null);
return returnUri;
}
throw new SQLException("Failed to insert row into " + uri);
}
}
use of android.database.SQLException in project FBReaderJ by geometer.
the class SQLiteConfig method requestAllValuesForGroup.
@Override
public synchronized List<String> requestAllValuesForGroup(String group) {
try {
final List<String> pairs = new LinkedList<String>();
final Cursor cursor = myDatabase.rawQuery("SELECT name,value FROM config WHERE groupName = ?", new String[] { group });
while (cursor.moveToNext()) {
pairs.add(cursor.getString(0) + "\000" + cursor.getString(1));
}
cursor.close();
return pairs;
} catch (SQLException e) {
return Collections.emptyList();
}
}
Aggregations