当前位置: 首页>>代码示例>>Java>>正文


Java SQLiteException类代码示例

本文整理汇总了Java中net.sqlcipher.database.SQLiteException的典型用法代码示例。如果您正苦于以下问题:Java SQLiteException类的具体用法?Java SQLiteException怎么用?Java SQLiteException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SQLiteException类属于net.sqlcipher.database包,在下文中一共展示了SQLiteException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkDataBase

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
private boolean checkDataBase() {

		SQLiteDatabase checkDB = null;

		try {
			String myPath = DB_PATH + DB_NAME;
			// checkDB = SQLiteDatabase.openDatabase(myPath,Password, null,
			// SQLiteDatabase.OPEN_READONLY);

			checkDB = SQLiteDatabase.openDatabase(myPath, null,
					SQLiteDatabase.NO_LOCALIZED_COLLATORS);
		} catch (SQLiteException e) {
			Logger.log(Log.DEBUG, tag,
					"Data base does not exist " + e.toString());
		}

		if (checkDB != null) {
			checkDB.close();
		}

		return checkDB != null;
	}
 
开发者ID:SEA2015-GROUP7,项目名称:projectTetViet,代码行数:23,代码来源:DataBaseManager.java

示例2: execute

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
    SQLiteStatement statement = null;
    try {
        statement = connection.getDatabase().compileStatement(sql);
        if (autoGeneratedKeys == RETURN_GENERATED_KEYS) {
            long rowId = statement.executeInsert();
            insertResult = new SingleResultSet(this, rowId);
            return true;
        } else {
            statement.execute();
        }
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    return false;
}
 
开发者ID:requery,项目名称:requery,代码行数:22,代码来源:SqlCipherStatement.java

示例3: executeUpdate

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
    SQLiteStatement statement = null;
    try {
        statement = connection.getDatabase().compileStatement(sql);
        if (autoGeneratedKeys == RETURN_GENERATED_KEYS) {
            long rowId = statement.executeInsert();
            insertResult = new SingleResultSet(this, rowId);
            return 1;
        } else {
            return updateCount = statement.executeUpdateDelete();
        }
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    return 0;
}
 
开发者ID:requery,项目名称:requery,代码行数:22,代码来源:SqlCipherStatement.java

示例4: queryMemory

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
protected <R> R queryMemory(Function<Cursor, R> function, String query) throws SQLException {
    try {
        final SQLiteDatabase database =
            SQLiteDatabase.openOrCreateDatabase(":memory:", "", null);
        Cursor cursor = database.rawQuery(query, null);
        return function.apply(closeWithCursor(new Closeable() {
            @Override
            public void close() throws IOException {
                database.close();
            }
        }, cursor));
    } catch (SQLiteException e) {
        throw new SQLException(e);
    }
}
 
开发者ID:requery,项目名称:requery,代码行数:17,代码来源:SqlCipherMetaData.java

示例5: getDaoFormValue

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
public Dao<FormValue, String> getDaoFormValue() {
    if (daoFormValue == null) {
        try {
            TableUtils.createTableIfNotExists(getOrmHelper().getConnectionSource(), FormValue.class);
            daoFormValue = getOrmHelper().getDao(FormValue.class);
            long count = getDaoForm().countOf();
            if (count < 1) {
                getForms(true);
            } else if (count < 2) {
                getForms(false);
            }
        } catch (SQLiteException | SQLException e) {
            Timber.e(e);
        }
    }
    return daoFormValue;
}
 
开发者ID:securityfirst,项目名称:Umbrella_android,代码行数:18,代码来源:Global.java

示例6: getDaoFeedSource

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
public Dao<FeedSource, String> getDaoFeedSource() {
    if (daoFeedSource == null) {
        try {
            TableUtils.createTableIfNotExists(getOrmHelper().getConnectionSource(), FeedSource.class);
            daoFeedSource = getOrmHelper().getDao(FeedSource.class);
            if (daoFeedSource.countOf() < 1) {
                daoFeedSource.create(new FeedSource("ReliefWeb", 0));
                daoFeedSource.create(new FeedSource("UN", 1));
                daoFeedSource.create(new FeedSource("FCO", 2));
                daoFeedSource.create(new FeedSource("CDC", 3));
                daoFeedSource.create(new FeedSource("Global Disaster and Alert Coordination System", 4));
                daoFeedSource.create(new FeedSource("US State Department Country Warnings", 5));
            }
        } catch (SQLiteException | SQLException e) {
            Timber.e(e);
        }
    }
    return daoFeedSource;
}
 
开发者ID:securityfirst,项目名称:Umbrella_android,代码行数:20,代码来源:Global.java

示例7: getSelectedFeedSources

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
public ArrayList<Integer> getSelectedFeedSources() {
    final CharSequence[] items = {"ReliefWeb", "UN", "FCO", "CDC", "Global Disaster and Alert Coordination System", "US State Department Country Warnings"};
    final ArrayList<Integer> selectedItems = new ArrayList<>();
    List<Registry> selections;
    try {
        selections = getDaoRegistry().queryForEq(Registry.FIELD_NAME, "feed_sources");
        for (int i = 0; i < items.length; i++) {
            for (Registry reg : selections) {
                if (reg.getValue().equals(String.valueOf(i))) {
                    selectedItems.add(i);
                    break;
                }
            }
        }
    } catch (SQLiteException | SQLException e) {
        Timber.e(e);
    }
    return selectedItems;
}
 
开发者ID:securityfirst,项目名称:Umbrella_android,代码行数:20,代码来源:Global.java

示例8: readExceptionFromParcel

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
private static final void readExceptionFromParcel(Parcel reply, String msg, int code) {
    switch (code) {
        case 2:
            throw new IllegalArgumentException(msg);
        case 3:
            throw new UnsupportedOperationException(msg);
        case 4:
            throw new SQLiteAbortException(msg);
        case 5:
            throw new SQLiteConstraintException(msg);
        case 6:
            throw new SQLiteDatabaseCorruptException(msg);
        case 7:
            throw new SQLiteFullException(msg);
        case 8:
            throw new SQLiteDiskIOException(msg);
        case 9:
            throw new SQLiteException(msg);
        default:
            reply.readException(code, msg);
    }
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:23,代码来源:DatabaseUtils.java

示例9: dumpCurrentRow

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
/**
 * Prints the contents of a Cursor's current row to a PrintSteam.
 *
 * @param cursor the cursor to print
 * @param stream the stream to print to
 */
public static void dumpCurrentRow(Cursor cursor, PrintStream stream) {
    String[] cols = cursor.getColumnNames();
    stream.println("" + cursor.getPosition() + " {");
    int length = cols.length;
    for (int i = 0; i< length; i++) {
        String value;
        try {
            value = cursor.getString(i);
        } catch (SQLiteException e) {
            // assume that if the getString threw this exception then the column is not
            // representable by a string, e.g. it is a BLOB.
            value = "<unprintable>";
        }
        stream.println("   " + cols[i] + '=' + value);
    }
    stream.println("}");
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:24,代码来源:DatabaseUtils.java

示例10: execSQL

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
protected void execSQL(String sql) throws SQLException {
    try {
        db.execSQL(sql);
    } catch (SQLiteException e) {
        throwSQLException(e);
    }
}
 
开发者ID:requery,项目名称:requery,代码行数:9,代码来源:SqlCipherConnection.java

示例11: executeQuery

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
public ResultSet executeQuery(String sql) throws SQLException {
    try {
        @SuppressLint("Recycle") // released with the queryResult
        Cursor cursor = connection.getDatabase().rawQuery(sql, null);
        return queryResult = new CursorResultSet(this, cursor, true);
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    }
    return null;
}
 
开发者ID:requery,项目名称:requery,代码行数:12,代码来源:SqlCipherStatement.java

示例12: execute

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
public boolean execute() throws SQLException {
    try {
        statement.execute();
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    }
    return false;
}
 
开发者ID:requery,项目名称:requery,代码行数:10,代码来源:SqlCipherPreparedStatement.java

示例13: executeQuery

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
@Override
public ResultSet executeQuery() throws SQLException {
    try {
        String[] args = bindingsToArray();
        cursor = connection.getDatabase().rawQuery(getSql(), args);
        return queryResult = new CursorResultSet(this, cursor, false);
    } catch (SQLiteException e) {
        SqlCipherConnection.throwSQLException(e);
    }
    return null;
}
 
开发者ID:requery,项目名称:requery,代码行数:12,代码来源:SqlCipherPreparedStatement.java

示例14: changePassword

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
/**
 * Change encrypted database password
 *
 * @param oldDbPassword Password current being used to access password in current session.
 *                      To restore state and continue with session.
 * @param oldPassword   Old password given by user via form to validate
 * @param newPassword   New password for database
 * @return              True if password changed successfully, else false
 */
private boolean changePassword(String oldDbPassword, String oldPassword, String newPassword) {
    DatabaseHandler db = SealnoteApplication.getDatabase();

    // Recycle old password, set new one and check if given old password
    // is correct
    db.recycle();
    try {
        db.setPassword(oldPassword);
        db.update();
    } catch (SQLiteException e) {
        db.recycle();

        // If timeout has occurred the old password will be null
        // and we don't have to put database to original state
        if (oldDbPassword != null && !oldDbPassword.equals("")) {
            db.setPassword(oldDbPassword);
            db.update();
        }
        return false;
    }

    // make query to change database key
    String query = String.format("PRAGMA rekey = %s", DatabaseUtils.sqlEscapeString(newPassword));
    db.getWritableDatabase().execSQL(query);
    db.getWritableDatabase().close();

    // Recycle old password and state, and set new password in handler
    db.recycle();
    SealnoteApplication.getDatabase().setPassword(newPassword);
    db.update();

    return true;
}
 
开发者ID:vishesh,项目名称:sealnote,代码行数:43,代码来源:PasswordPreference.java

示例15: checkDatabasePassword

import net.sqlcipher.database.SQLiteException; //导入依赖的package包/类
/**
 * Public check database password
 */
public static boolean checkDatabasePassword(Context context, File file, String password) {
    try {
        SQLiteDatabase database = new SQLiteDatabase(file.getPath(),
                password.toCharArray(), null, 0);
        database.close();
    } catch (SQLiteException e) {
        return false;
    }
    return true;
}
 
开发者ID:vishesh,项目名称:sealnote,代码行数:14,代码来源:BackupUtils.java


注:本文中的net.sqlcipher.database.SQLiteException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。