static sqlite3 *__db_init(char *root) { int r; sqlite3 *db = NULL; r = db_util_open(root, &db, 0); if (r) { LOGE("db util open error(%d)", r); db_util_close(db); return NULL; } r = __create_table(db); if (r) { LOGE("create table error(%d)", r); db_util_close(db); return NULL; } return db; }
int rua_fini(void) { unsigned int timestamp; timestamp = PERF_MEASURE_START("RUA"); LOGD("rua_fini invoked"); if (_db) { db_util_close(_db); _db = NULL; } PERF_MEASURE_END("RUA", timestamp); return 0; }
int notification_db_close(sqlite3 ** db) { int ret = 0; if (db == NULL || *db == NULL) { return NOTIFICATION_ERROR_INVALID_DATA; } ret = db_util_close(*db); if (ret != SQLITE_OK) { NOTIFICATION_ERR("DB close error(%d)", ret); return NOTIFICATION_ERROR_FROM_DB; } *db = NULL; return NOTIFICATION_ERROR_NONE; }
void SqlConnection::Disconnect() { if (m_connection == NULL) { LogPedantic("Already disconnected."); return; } LogPedantic("Disconnecting from DB..."); // All stored data commands must be deleted before disconnect Assert(m_dataCommandsCount == 0 && "All stored procedures must be deleted" " before disconnecting SqlConnection"); int result; if (m_usingLucene) { result = db_util_close(m_connection); } else { result = sqlite3_close(m_connection); } if (result != SQLITE_OK) { const char *error = sqlite3_errmsg(m_connection); LogPedantic("SQL close failed"); LogPedantic(" Error: " << error); Throw(Exception::InternalError); } m_connection = NULL; LogPedantic("Disconnected from DB"); }