本文整理汇总了C++中database_error函数的典型用法代码示例。如果您正苦于以下问题:C++ database_error函数的具体用法?C++ database_error怎么用?C++ database_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了database_error函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: noexcept
transaction::~transaction() noexcept(false)
{
if (db_) {
auto rc = db_->execute(fcommit_ ? "COMMIT" : "ROLLBACK");
if (rc != SQLITE_OK)
throw database_error(*db_);
}
}
开发者ID:authurlan,项目名称:sqlite3pp,代码行数:8,代码来源:sqlite3pp.cpp
示例2: db_
database::database(char const* dbname, int flags, char const* vfs) : db_(nullptr)
{
if (dbname) {
auto rc = connect(dbname, flags, vfs);
if (rc != SQLITE_OK)
throw database_error("can't connect database");
}
}
开发者ID:authurlan,项目名称:sqlite3pp,代码行数:8,代码来源:sqlite3pp.cpp
示例3: conn
postgresql_statement::postgresql_statement(shared_ptr<postgresql_connection_impl> conn,
const string &query)
: conn(conn)
{
postgresql_result res(PQprepare(conn->get(), "", convert_query(query).c_str(), 0, NULL));
if (!res.command_ok())
throw database_error(PQresultErrorMessage(res.get()));
}
开发者ID:beam2d,项目名称:pficommon,代码行数:9,代码来源:statement.cpp
示例4: m_db
sqlite3_connection::sqlite3_connection( sqlite3 * dbh )
: m_db(0), m_name()
{
if( ! dbh )
{
throw database_error( "sqlite3_connection(sqlite3*) ctor was passed a null db handle." );
}
this->take( dbh );
}
开发者ID:B-Rich,项目名称:temporal-hex-dump,代码行数:9,代码来源:sqlite3x_connection.cpp
示例5: database_error
void sqlite3_command::finalize()
{
if( this->stmt )
{
if(sqlite3_finalize(this->stmt)!=SQLITE_OK)
throw database_error(this->con);
this->stmt = 0;
}
}
开发者ID:B-Rich,项目名称:temporal-hex-dump,代码行数:9,代码来源:sqlite3x_command.cpp
示例6: PQreset
void postgresql_connection_impl::reconnect()
{
if (PQstatus(conn)==CONNECTION_OK)
return;
PQreset(conn);
if (PQstatus(conn)!=CONNECTION_OK)
throw database_error("fail to reconnect");
}
开发者ID:beam2d,项目名称:pficommon,代码行数:10,代码来源:connection.cpp
示例7: update_db
void update_db(const char *sql) {
sqlite3 *db;
int ret;
char *errmsg;
db = get_db();
ret = sqlite3_exec(db, sql, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
database_error(errmsg, sql);
}
}
开发者ID:guo-shaoge,项目名称:flask_learnC,代码行数:11,代码来源:database_lib.c
示例8: m_pimpl
table_generator::table_generator( sqlite3_connection & con, std::string const & n )
: m_pimpl( new table_generator::table_generator_impl )
{
int check = con.executeint( "select count(*) from sqlite_master where type like 'table' and name like '"+n+"'" );
// ^^^ we use 'like' here because sqlite3 is case-insensitive
if( 0 != check )
{
throw database_error( "table_generator() db table '%s' already exists.", n.c_str() );
}
this->m_pimpl->db = &con;
this->m_pimpl->name = n;
}
开发者ID:B-Rich,项目名称:temporal-hex-dump,代码行数:12,代码来源:sqlite3x_connection.cpp
示例9: sqlite3_prepare
void sqlite3_command::prepare( char const * sql, int len )
{
if( this->stmt ) this->finalize();
const char *tail=NULL;
int rc = sqlite3_prepare( this->con.db(), sql, len, &(this->stmt), &tail );
if( SQLITE_OK != rc )
{
throw database_error("sqlite3_command::prepare([%s]) failed. Reason=[%s]",
sql, sqlite3_errmsg( this->con.db() ) );
}
this->argc=sqlite3_column_count(this->stmt);
}
开发者ID:B-Rich,项目名称:temporal-hex-dump,代码行数:12,代码来源:sqlite3x_command.cpp
示例10: load_add_class
/* Return False on error, True on success */
int load_add_class(char *class_name, int class_id, int superclass_id, char *superclass_name)
{
/* Build up a class data structure for the new class. */
id_type id = (id_type)SafeMalloc(sizeof(id_struct));
id_type temp_id = (id_type)SafeMalloc(sizeof(id_struct));
class_type c = (class_type)SafeMalloc(sizeof(class_struct));
// Adding new built-in object types will render existing kodbase.txt files
// incompatible. This isn't a problem as a pre-existing kodbase.txt is only
// required for reloading a live server, so a new one can be made. Check
// for built-in class name/ID mismatches here and instruct the user to
// delete kodbase.txt if this check fails.
extern id_struct BuiltinIds[];
if ((strcmp(BuiltinIds[SETTINGS_CLASS].name, class_name) == 0
&& class_id != SETTINGS_CLASS)
|| (strcmp(BuiltinIds[REALTIME_CLASS].name, class_name) == 0
&& class_id != REALTIME_CLASS)
|| (strcmp(BuiltinIds[EVENTENGINE_CLASS].name, class_name) == 0
&& class_id != EVENTENGINE_CLASS))
{
database_error("Incompatible kodbase.txt. Delete the file and recompile.");
return False;
}
id->name = strdup(class_name);
id->idnum = class_id;
id->type = I_CLASS;
id->source = DBASE;
c->class_id = id;
c->properties = c->messages = c->resources = c->classvars = NULL;
c->is_new = False; /* Don't generate code for this class */
/* Store superclass id # in pointer for now. Id # will be converted to pointer
* when build_superclasses below is called. */
c->superclass = (class_type) superclass_id;
/* Add to list of classes that have been read in */
st.classes = list_add_item(st.classes, (void *) c);
current_class = c;
st.curclass = class_id;
current_message = NULL;
/* Call table_insert instead of add_identifier so that our id # from
* the database file is preserved.
*/
if (table_insert(st.globalvars, (void *) id, id_hash, id_compare) == 0)
return True;
else return False;
}
开发者ID:GarOfMeridian,项目名称:Meridian59_103,代码行数:52,代码来源:kodbase.c
示例11: database_error
void sqlite3_connection::open(const wchar_t *db) {
if(sqlite3_open16(db, &this->m_db)!=SQLITE_OK)
throw database_error("unable to open database");
try
{
this->on_open();
}
catch(...)
{
try { this->close(); }
catch(...) { /* ignore */ }
throw;
}
}
开发者ID:B-Rich,项目名称:temporal-hex-dump,代码行数:14,代码来源:sqlite3x_connection.cpp
示例12: database_error
void Database::open(std::string fname)
{
sqlite3* db=NULL;
try{
//TODO UTF-8 string
int rc=sqlite3_open(fname.c_str(), &db);
if(rc!=SQLITE_OK)
throw database_error( std::string("database error: ")+sqlite3_errmsg(db) );
con=shared_connection(new autoclosed_con(db));
}catch(std::runtime_error e){
if(db)
sqlite3_close(db);
throw e;
}
}
开发者ID:phambryan,项目名称:hiberlite,代码行数:17,代码来源:Database.cpp
示例13: database_error
void
router::set_nodes_total(const size_t total, vm::all *all)
{
nodes_per_remote = total / world_size;
#ifndef USE_SIM
if(nodes_per_remote == 0)
throw database_error("Number of nodes is less than the number of remote machines");
#endif
all->NUM_NODES_PER_PROCESS = nodes_per_remote;
// cache values for each remote
for(remote::remote_id i(0); i != (remote::remote_id)world_size; ++i)
remote_list[i]->cache_values(world_size, nodes_per_remote, total);
}
开发者ID:flavioc,项目名称:meld,代码行数:17,代码来源:router.cpp
示例14: get_data_input
/*
* 从DATA_IN中读取用户的输入,比如scanf 需要的输入就从这里得到
*/
void get_data_input(char *code_id) {
char sql[SQL_LEN] = {0};
char *errmsg;
int ret;
sqlite3 *db;
FILE *fp = fopen(DATA_IN, "w");
if (fp == NULL) {
write_log(INT_RE, 1, "fopen error(in get_data_input)");
exit(-1);
}
sprintf(sql, "select data_input from code where code_id='%s'", code_id);
db = get_db();
ret = sqlite3_exec(db, (const char*)sql, get_data_input_cb,\
(void*)fp, &errmsg);
fclose(fp);
if (ret != SQLITE_OK) {
database_error(errmsg, sql);
}
}
开发者ID:guo-shaoge,项目名称:flask_learnC,代码行数:24,代码来源:database_lib.c
示例15: load_add_resource
int load_add_resource(char *resource_name, int resource_id)
{
id_type id = (id_type) SafeMalloc(sizeof(id_struct));
resource_type r = (resource_type) SafeMalloc(sizeof(resource_struct));
id->name = strdup(resource_name);
id->idnum = resource_id;
id->type = I_RESOURCE;
id->ownernum = st.curclass;
id->source = DBASE;
r->lhs = id;
r->rhs = NULL;
/* Add resource to resource list of current class */
if (current_class == NULL)
database_error("Resource appears outside of class in database file");
current_class->resources = list_add_item(current_class->resources, (void *) r);
/* OK if parameter already in table; just ignore return value */
table_insert(st.globalvars, (void *) id, id_hash, id_compare);
return True;
}
开发者ID:Darkman-M59,项目名称:Meridian59_115,代码行数:23,代码来源:kodbase.c
示例16: database_error
void sqlite3_reader::reset() {
if(!this->cmd) throw database_error("reader is closed");
if(sqlite3_reset(this->cmd->stmt)!=SQLITE_OK)
throw database_error(&this->cmd->m_con);
}
开发者ID:3F,项目名称:FlightSDCpp,代码行数:6,代码来源:sqlite3x_reader.cpp
示例17: database_error
void sqlite3_command::bind(int index, const void *data, int datalen) {
if(sqlite3_bind_blob(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)
throw database_error(this->con);
}
开发者ID:Tudi,项目名称:PG2-firewall,代码行数:4,代码来源:command.cpp
示例18:
std::string sqlite3_command::executeblob() {
sqlite3_reader reader=this->executereader();
if(!reader.read()) throw database_error("nothing to read");
return reader.getblob(0);
}
开发者ID:Tudi,项目名称:PG2-firewall,代码行数:5,代码来源:command.cpp
示例19: eexecute
void database::execute(char const* sql)
{
const int rc = eexecute(sql);
if (rc != SQLITE_OK)
throw database_error(*this);
}
开发者ID:larroy,项目名称:sqlite3pp,代码行数:6,代码来源:sqlite3pp.cpp
注:本文中的database_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论