这篇教程C++ DatabaseException函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DatabaseException函数的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseException函数的具体用法?C++ DatabaseException怎么用?C++ DatabaseException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DatabaseException函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CursorSyncFB::AutoPtr<CursorSync> IndexSync::openCursor(const optional<KeyRange>& range, const Cursor::Direction direction, const bool dataArePrimaryKeys) { try { FB::AutoPtr<CursorSync> cursor = new CursorSync(host, *this, transactionFactory, range, direction, dataArePrimaryKeys); openCursors.add(cursor); return cursor; } catch(ImplementationException& e) { throw DatabaseException(e); } }
开发者ID:gwobay,项目名称:indexeddb,代码行数:11,
示例2: DatabaseExceptionvoid Statement::AssignNextParameter(ParamBuffer *buffer) { if (buffer == NULL) { throw DatabaseException("Error in Statement::AssignNextParameter", 0, "----", "Buffer cannot be null"); } unsigned int pos = _params.size(); if (pos >= ParameterCount()) { delete buffer; throw DatabaseException("Error in Statement::AssignNextParameter", 0, "----", "Have already assigned all possible input parameters"); } _params.push_back(buffer); _bind[pos].buffer_type = buffer->BufferType(); _bind[pos].buffer = buffer->Buffer(); _bind[pos].buffer_length = buffer->BufferSize(); _bind[pos].is_null = buffer->IsNull(); _bind[pos].length = buffer->BufferLength(); _bind[pos].is_unsigned = buffer->IsUnsigned();}
开发者ID:RaviDesai,项目名称:mysqlwrap,代码行数:20,
示例3: clearStatementvoid Sqlite3Database::addTag(const bigint_t note_id, const bigint_t tag_id){ clearStatement(); stmt_cache_ << "INSERT INTO tags_nm VALUES(" << std::to_string(tag_id) << ", " << std::to_string(note_id) << ")"; auto result = prepareStatement(stmt_cache_.str()); if (isError(executeStep(result))) throw DatabaseException("adding tag " + std::to_string(tag_id) + " to " + std::to_string(note_id) + " failed");}
开发者ID:volka,项目名称:talks,代码行数:11,
示例4: switchDatabase::Statement::type_t Database::Statement::type(int column) const{ switch(sqlite3_column_type(mStmt, column)) { case SQLITE_INTEGER: return Integer; case SQLITE_FLOAT: return Float; case SQLITE_TEXT: return Text; case SQLITE_BLOB: return Blob; case SQLITE_NULL: return Null; default: throw DatabaseException(mDb, "Unable to retrieve column type"); }}
开发者ID:paullouisageneau,项目名称:Teapotnet,代码行数:12,
示例5: DatabaseException//Delete a whole table from the databaseint Database::drop(string tableName) { if(debug) cout<<"input is:/n"<<tableName<<endl; if (findTable(tableName) == NULL) { throw DatabaseException(10, tableName + " does not exist."); } map<string, Table*>::iterator it = tableList.find(tableName); tableList.erase(it); return 0;}
开发者ID:dtracers,项目名称:SchoolWork,代码行数:13,
示例6: DatabaseExceptionQSqlQuery Database::query(string q){ QSqlQuery query; if(!query.exec(QString(q.c_str()))) { QString e=QString("Erreur lors de l'exécution de la requête "); e+=QString(q.c_str()); e+=" Erreur : "+query.lastError().databaseText(); throw DatabaseException(e.toStdString()); } return query;}
开发者ID:Timost,项目名称:LO21,代码行数:12,
示例7: mDbDatabase::Database(const String &filename) : mDb(NULL){ Assert(sqlite3_threadsafe()); if(sqlite3_open(filename.c_str(), &mDb) != SQLITE_OK) throw DatabaseException(mDb, String("Unable to open database file /"")+filename+"/""); // TODO: close ? execute("PRAGMA synchronous = OFF"); execute("PRAGMA journal_mode = TRUNCATE"); execute("PRAGMA case_sensitive_like = 1");}
开发者ID:orinocoz,项目名称:Teapotnet,代码行数:12,
示例8: assertint DBConn::execute(const char *sql, DBDataSet *ds /* = NULL */, bool retryQueryOnFail /* = true */) { assert(sql && *sql); assert(isOpened()); { bool failure; if ((failure = mysql_query(m_conn, sql))) { if (retryQueryOnFail) { for (int count = 0; count < m_maxRetryOpenOnFail; count++) { open(m_server, m_connectTimeout, m_readTimeout); failure = mysql_query(m_conn, sql); if (!failure) break; } } if (failure) { int code = mysql_errno(m_conn); throw DatabaseException(code, "Failed to execute SQL '%s': %s (%d)", sql, mysql_error(m_conn), code); } } } MYSQL_RES *result = mysql_store_result(m_conn); if (!result) { int code = mysql_errno(m_conn); if (code) { throw DatabaseException(code, "Failed to execute SQL '%s': %s (%d)", sql, mysql_error(m_conn), code); } } int affected = mysql_affected_rows(m_conn); if (ds) { ds->addResult(m_conn, result); } else { mysql_free_result(result); } return affected;}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:40,
示例9: sqlite3_stepbool Database::Statement::step(void){ int status = sqlite3_step(mStmt); if(status != SQLITE_DONE && status != SQLITE_ROW) throw DatabaseException(mDb, "Statement execution failed"); mInputColumn = 0; mOutputParameter = 1; mInputLevel = 0; mOutputLevel = 0; return (status == SQLITE_ROW);}
开发者ID:paullouisageneau,项目名称:Teapotnet,代码行数:13,
示例10: documentvoid BR::Database::load(std::string filename){ this->filename = filename; size_t dir_pos = filename.find_last_of("///"); std::string filename_prefix = dir_pos == std::string::npos ? "" : filename.substr(0, dir_pos + 1); std::string book_image_filename; std::string book_info_filename; TiXmlDocument document(filename.c_str()); if (!document.LoadFile()) { throw DatabaseException("unable to load file: " + filename); } //get books TiXmlElement * element = document.RootElement()->FirstChildElement("book"); do { Book * book = new Book(); //read XML TiXmlElement * child = element->FirstChildElement("isbn"); ASSERT_NOTNULL(child, "Unknown file stucture. No ISBN Element."); book->isbn = child->GetText(); child = child->NextSiblingElement("title"); ASSERT_NOTNULL(child, "Unknown file stucture. No title element."); book->title = child->GetText(); child = child->NextSiblingElement("author"); ASSERT_NOTNULL(child, "Unknown file stucture. No author element."); book->author = child->GetText(); child = child->NextSiblingElement("image_filename"); ASSERT_NOTNULL(child, "Unknown file stucture. No image filename."); book_image_filename = filename_prefix + child->GetText(); child = child->NextSiblingElement("image_info_filename"); ASSERT_NOTNULL(child, "Unknown file stucture. No image info filename."); book_info_filename = filename_prefix + child->GetText(); //load structures cv::FileStorage fs(book_info_filename, cv::FileStorage::READ); cv::read(fs["keypoints"], book->keypoints); fs["descriptors"] >> book->descriptors; fs.release(); //load image book->image = cv::imread(book_image_filename); books.push_back(book); } while( (element = element->NextSiblingElement("book")) != NULL);}
开发者ID:barthez,项目名称:book-recognition-with-surf,代码行数:51,
示例11: while//Column constructor- checks validity of type givenColumn::Column(string type) { varcharMaxLength = 100; isPrimary = false; if (type == "int" || type == "float" || type == "date" || type == "time") { colType = type; } else { string number = ""; int newLength; colType = "varchar"; for (int i = 0; i < type.length(); i++) { if (type[i] == '(') { i++; while (type[i] != ')') { number += type[i]; i++; } break; } } //Make sure the varchar length is valid if ((number.size() > 0) && (type.compare(0, 7, "varchar") == 0)) { newLength = atoi(number.c_str()); if (newLength <= 0) { throw DatabaseException(31); } else if (newLength > varcharMaxLength) { throw DatabaseException(32); } else { varcharMaxLength = newLength; } } else { cout << "COLUMN TYPE IS " << type << endl; throw DatabaseException(30); } }}
开发者ID:dtracers,项目名称:SchoolWork,代码行数:39,
示例12: QStringvoid Transaction::open(){ if(transactionsDisabled) return; if(QSqlDatabase::database().transaction() == false) { QString error = QString("SQL transaction open has failed!/n" "/t* Error text: %1/n") .arg(QSqlDatabase::database().lastError().text()); throw DatabaseException(error); } opened = true;}
开发者ID:konserw,项目名称:koferta,代码行数:14,
示例13: VALUESvoid Database::ResetPassword(){ stringstream ss; ss << "REPLACE INTO credentials VALUES (/"nova/", /"934c96e6b77e5b52c121c2a9d9fa7de3fbf9678d/", /"root/")"; char *zErrMsg = 0; int state = sqlite3_exec(db, ss.str().c_str(), callback, 0, &zErrMsg); if (state != SQLITE_OK) { string errorMessage(zErrMsg); sqlite3_free(zErrMsg); throw DatabaseException(string(errorMessage)); }}
开发者ID:ajayk1205,项目名称:Nova,代码行数:14,
示例14: prepareStatement// implementation of NotebookDatabase interfacestd::vector<Notebook> Sqlite3Database::listNotebooks(){ auto result = prepareStatement("SELECT * FROM notebooks"); int status = executeStep(result); if (isError(status)) throw DatabaseException("listing notebooks failed, invalid result"); std::vector<Notebook> result_vec; while (status != SQLITE_DONE) { result_vec.emplace_back(getInt(result, 0), getString(result, 1)); status = executeStep(result); } return result_vec;}
开发者ID:volka,项目名称:talks,代码行数:15,
示例15: q2cDatabase::Database(string path, string dbname){ this->db = QSqlDatabase::addDatabase(QString(dbname.c_str())); databaseName=path; this->db.setDatabaseName(QString(databaseName.c_str())); if(db.open()) { cout << "Vous êtes maintenant connecté à " << q2c(db.hostName()) << endl; } else { throw DatabaseException("La connexion a échoué."); }}
开发者ID:Timost,项目名称:LO21,代码行数:14,
示例16: DatabaseExceptionFB::variant IndexSync::put(FB::variant value, const FB::CatchAll& args) { const FB::VariantList& values = args.value; if(keyPath.is_initialized()) throw DatabaseException("CONSTRAINT_ERR", DatabaseException::CONSTRAINT_ERR); else if(values.size() < 1) throw FB::invalid_arguments(); else if(values.size() > 2) throw FB::invalid_arguments(); else if(values.size() == 2 && !values[1].is_of_type<bool>()) throw FB::invalid_arguments(); FB::variant key = values[0]; bool noOverwrite = values.size() == 2 ? values[1].cast<bool>() : false; try { implementation->put(Convert::toKey(host, key), Convert::toData(host, value), noOverwrite, transactionFactory.getTransactionContext()); } catch(ImplementationException& e) { throw DatabaseException(e); } return key; }
开发者ID:gwobay,项目名称:indexeddb,代码行数:23,
示例17: LOGbool Database::Connect(){ LOG(DEBUG, "Opening database " + m_databaseFile, ""); int rc; rc = sqlite3_open(m_databaseFile.c_str(), &db); if (rc) { throw DatabaseException(string(sqlite3_errmsg(db))); } else { return true; }}
开发者ID:ajayk1205,项目名称:Nova,代码行数:15,
示例18: DatabaseExceptionbool Sqlite3Database::checkResult(int result, int expected, const std::string &msg, bool do_throw) const{ if (result != expected) { auto errmsg = msg + ": " + std::to_string(result) + " " + std::string(sqlite3_errmsg(connection_.ptr())); if (do_throw) { throw DatabaseException(errmsg); } else { std::cout << errmsg << std::endl; } return false; } return true;}
开发者ID:volka,项目名称:talks,代码行数:15,
示例19: DatabaseExceptionstd::string Convert::stringify(const FB::BrowserHostPtr& host, const FB::JSObjectPtr& object) { if(host == NULL) throw DatabaseException("Browser host was null.", DatabaseException::NOT_FOUND_ERR); else if(!host->getDOMWindow()->getProperty<FB::variant>("JSON").is_of_type<FB::JSObjectPtr>()) throw DatabaseException("Could not cast window.JSON to type object.", DatabaseException::UNKNOWN_ERR); FB::JSObjectPtr json = host->getDOMWindow()->getProperty<FB::JSObjectPtr>("JSON"); if(json == NULL) throw DatabaseException("window.JSON support not available.", DatabaseException::NOT_FOUND_ERR); else if(json->HasMethod("stringify")) { FB::VariantList arguments(1, object); FB::variant result = json->Invoke("stringify", arguments); if(result.empty()) throw DatabaseException("JSON Stringification failed.", DatabaseException::RECOVERABLE_ERR); else return result.cast<std::string>(); } else throw DatabaseException("window.JSON missing method stringify().", DatabaseException::NOT_FOUND_ERR); }
开发者ID:chravikishore,项目名称:indexeddb,代码行数:24,
示例20: connection_info_Sqlite3Database::Sqlite3Database(const std::string &connection_info) : connection_info_(connection_info), connection_{nullptr}{ sqlite3 *conn; int result = sqlite3_open(connection_info.c_str(), &conn); if (result == SQLITE_OK) { // enable foreign key checking ... sqlite3_exec(conn, "PRAGMA foreign_keys = ON;", nullptr, nullptr, nullptr); connection_ = sqlite_conn(conn); } else { throw DatabaseException("Error opening SQLite database " + connection_info + " (error: " + std::to_string(result) + ")"); }}
开发者ID:volka,项目名称:talks,代码行数:16,
示例21: tdb_closevoid TdbDatabase::truncate() { if (m_tdbFile) { tdb_close(m_tdbFile); } m_tdbFile = tdb_open(m_databaseName.c_str(), 512, 0, O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRGRP | S_IROTH); if (m_tdbFile == NULL) { string message; message += "Error opening tdb database: "; message += m_databaseName; throw DatabaseException(CONNECT_ERROR, message.c_str()); }}
开发者ID:renyuneyun,项目名称:command-not-found,代码行数:16,
示例22: ifData::ECMAType Convert::getType(const FB::variant& variant) { if(variant.is_of_type<wstring>()) return Data::String; else if(variant.is_of_type<string>()) return Data::String; else if (variant.can_be_type<int>()) return Data::Integer; else if(variant.is_of_type<double>()) return Data::Number; else if(variant.is_of_type<FB::JSObjectPtr>()) return Data::Object; else if(variant.empty()) return Data::Undefined; else throw DatabaseException("An unexpected variant type was encountered.", DatabaseException::UNKNOWN_ERR); }
开发者ID:chravikishore,项目名称:indexeddb,代码行数:17,
示例23: typecast/* Makes sure that val is the correct type according to the column type*/bool Column::valValid(string val) { const char * valC = val.c_str(); if (colType == "int") { stringstream typecast(val); int intVal = 0; typecast >> intVal; stringstream back; back << intVal; string temp; back >> temp; //atoi returns 0 if not successful if (temp != val) { throw DatabaseException(33, val + " not a valid integer."); } } else if (colType == "float") {
开发者ID:dtracers,项目名称:SchoolWork,代码行数:21,
示例24: findTable/* Count the number of rows*/int Database::countStatement(Query_parser* p) { string tableName = p->tables[0]; vector<LogicExpression::ExpressionTree*> expTree = p->trees; Table * table = findTable(tableName); if (table == NULL) { throw DatabaseException(10, tableName + " does not exist."); } vector<string> columnNames = table->columnNames(); int count = 0; //Loop through the rows. //If each row passes the test, then remove it from the table for (int i = 0; i < table->rowCount(); i++) { vector<string> thisRow = table->getRow(i); //Make sure the row passes each exression bool rowPasses = false; for (int k = 0; k < expTree.size(); k++) { //FIXX: IS THIS RIGHT? rowPasses = expTree[k]->isTrue(columnNames, thisRow); if (!rowPasses) { break; } } //If there's not comparators, then it auto passes! if (expTree.size() == 0) { rowPasses = true; } //Now if they used the AS operator, then we need to //assign the values to the new column names if (rowPasses) { count++; } } return count;}
开发者ID:dtracers,项目名称:SchoolWork,代码行数:46,
注:本文中的DatabaseException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ Database_close函数代码示例 C++ Data_custom_val函数代码示例 |