Loading core/jni/android_database_SQLiteCommon.cpp +12 −10 Original line number Diff line number Diff line Loading @@ -33,8 +33,11 @@ void throw_sqlite3_exception(JNIEnv* env, const char* message) { */ void throw_sqlite3_exception(JNIEnv* env, sqlite3* handle, const char* message) { if (handle) { throw_sqlite3_exception(env, sqlite3_errcode(handle), sqlite3_errmsg(handle), message); // get the error code and message from the SQLite connection // the error message may contain more information than the error code // because it is based on the extended error code rather than the simplified // error code that SQLite normally returns. throw_sqlite3_exception(env, sqlite3_errcode(handle), sqlite3_errmsg(handle), message); } else { // we use SQLITE_OK so that a generic SQLiteException is thrown; // any code not specified in the switch statement below would do. Loading @@ -42,16 +45,14 @@ void throw_sqlite3_exception(JNIEnv* env, sqlite3* handle, const char* message) } } /* throw a SQLiteException for a given error code */ /* throw a SQLiteException for a given error code * should only be used when the database connection is not available because the * error information will not be quite as rich */ void throw_sqlite3_exception_errcode(JNIEnv* env, int errcode, const char* message) { if (errcode == SQLITE_DONE) { throw_sqlite3_exception(env, errcode, NULL, message); } else { char temp[21]; sprintf(temp, "error code %d", errcode); throw_sqlite3_exception(env, errcode, temp, message); } } /* throw a SQLiteException for a given error code, sqlite3message, and user message Loading @@ -75,6 +76,7 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode, break; case SQLITE_DONE: exceptionClass = "android/database/sqlite/SQLiteDoneException"; sqlite3Message = NULL; // SQLite error message is irrelevant in this case break; case SQLITE_FULL: exceptionClass = "android/database/sqlite/SQLiteFullException"; Loading core/jni/android_database_SQLiteConnection.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ static int executeNonQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3_st throw_sqlite3_exception(env, "Queries can be performed using SQLiteDatabase query or rawQuery methods only."); } else if (err != SQLITE_DONE) { throw_sqlite3_exception_errcode(env, err, sqlite3_errmsg(connection->db)); throw_sqlite3_exception(env, connection->db); } return err; } Loading Loading @@ -479,7 +479,7 @@ static jlong nativeExecuteForLastInsertedRowId(JNIEnv* env, jclass clazz, static int executeOneRowQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3_stmt* statement) { int err = sqlite3_step(statement); if (err != SQLITE_ROW) { throw_sqlite3_exception_errcode(env, err, sqlite3_errmsg(connection->db)); throw_sqlite3_exception(env, connection->db); } return err; } Loading Loading
core/jni/android_database_SQLiteCommon.cpp +12 −10 Original line number Diff line number Diff line Loading @@ -33,8 +33,11 @@ void throw_sqlite3_exception(JNIEnv* env, const char* message) { */ void throw_sqlite3_exception(JNIEnv* env, sqlite3* handle, const char* message) { if (handle) { throw_sqlite3_exception(env, sqlite3_errcode(handle), sqlite3_errmsg(handle), message); // get the error code and message from the SQLite connection // the error message may contain more information than the error code // because it is based on the extended error code rather than the simplified // error code that SQLite normally returns. throw_sqlite3_exception(env, sqlite3_errcode(handle), sqlite3_errmsg(handle), message); } else { // we use SQLITE_OK so that a generic SQLiteException is thrown; // any code not specified in the switch statement below would do. Loading @@ -42,16 +45,14 @@ void throw_sqlite3_exception(JNIEnv* env, sqlite3* handle, const char* message) } } /* throw a SQLiteException for a given error code */ /* throw a SQLiteException for a given error code * should only be used when the database connection is not available because the * error information will not be quite as rich */ void throw_sqlite3_exception_errcode(JNIEnv* env, int errcode, const char* message) { if (errcode == SQLITE_DONE) { throw_sqlite3_exception(env, errcode, NULL, message); } else { char temp[21]; sprintf(temp, "error code %d", errcode); throw_sqlite3_exception(env, errcode, temp, message); } } /* throw a SQLiteException for a given error code, sqlite3message, and user message Loading @@ -75,6 +76,7 @@ void throw_sqlite3_exception(JNIEnv* env, int errcode, break; case SQLITE_DONE: exceptionClass = "android/database/sqlite/SQLiteDoneException"; sqlite3Message = NULL; // SQLite error message is irrelevant in this case break; case SQLITE_FULL: exceptionClass = "android/database/sqlite/SQLiteFullException"; Loading
core/jni/android_database_SQLiteConnection.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -444,7 +444,7 @@ static int executeNonQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3_st throw_sqlite3_exception(env, "Queries can be performed using SQLiteDatabase query or rawQuery methods only."); } else if (err != SQLITE_DONE) { throw_sqlite3_exception_errcode(env, err, sqlite3_errmsg(connection->db)); throw_sqlite3_exception(env, connection->db); } return err; } Loading Loading @@ -479,7 +479,7 @@ static jlong nativeExecuteForLastInsertedRowId(JNIEnv* env, jclass clazz, static int executeOneRowQuery(JNIEnv* env, SQLiteConnection* connection, sqlite3_stmt* statement) { int err = sqlite3_step(statement); if (err != SQLITE_ROW) { throw_sqlite3_exception_errcode(env, err, sqlite3_errmsg(connection->db)); throw_sqlite3_exception(env, connection->db); } return err; } Loading