本文整理汇总了C++中DatabaseException函数的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseException函数的具体用法?C++ DatabaseException怎么用?C++ DatabaseException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CursorSync
FB::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); }
}
示例2: DatabaseException
void 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();
}
示例3: clearStatement
void 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");
}
示例4: switch
Database::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");
}
}
示例5: DatabaseException
//Delete a whole table from the database
int 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;
}
示例6: DatabaseException
QSqlQuery 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;
}
示例7: mDb
Database::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");
}
示例8: assert
int 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;
}
示例9: sqlite3_step
bool 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);
}
示例10: document
void 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);
}
示例11: while
//Column constructor- checks validity of type given
Column::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);
}
}
}
示例12: QString
void 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;
}
示例13: VALUES
void 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));
}
}
示例14: prepareStatement
// implementation of NotebookDatabase interface
std::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;
}
示例15: q2c
Database::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é.");
}
}