当前位置: 首页>>代码示例>>C++>>正文


C++ DatabaseConnection类代码示例

本文整理汇总了C++中DatabaseConnection的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseConnection类的具体用法?C++ DatabaseConnection怎么用?C++ DatabaseConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DatabaseConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: databaseConnection

QStringList Project::databaseFieldList( const QString &connection, const QString &table )
{
    DatabaseConnection *conn = databaseConnection( connection );
    if ( !conn )
	return QStringList();
    return conn->fields( table );
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:7,代码来源:project.cpp

示例2: disconnected

/**
 *
 * We received a disconnect signal. Lets cleanup the connection in question
 *
 * @param args The arguments passed from the database
 * @return void
 */
void DatabaseConnectionManager::disconnected(const VariantVector &args)
{
    DatabaseConnection *connection;
    std::string uuid;
    Variant uid = args.data()[0];

    uuid = uid.toString();

    // Find connection
    connection = disconnectingConnections[uuid];

    // Stop running
    connection->stop();

    // Wait for the connection to finish
    while (!connection->isFinished()) {

        // Process any pending events
        Application::getInstance()->processEvents();

        // Sleep for 30ms.
        usleep(30 * 1000);
    }

    // Remove from collection
    disconnectingConnections.erase(uuid);

    // Free memory
    if (connection != mainConnection) {
        delete connection;
    }
}
开发者ID:RabidSQL,项目名称:backend,代码行数:39,代码来源:DatabaseConnectionManager.cpp

示例3: lock

//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
DatabaseService::onDestroy(wpDatabaseConnection_type _pConnection)
{
    Threading::CriticalSection lock(m_pConnectionsGuard);

    connections_types::iterator iter = m_namedConnections.find(_pConnection->getName());
    if (iter != m_namedConnections.end())
    {
        // This is safe since the only place that this can transition
        // from expired to non-expired is in connect() where m_pConnectionsGuard
        // is acquired.
        if (iter->second.expired())
        {
            m_namedConnections.erase(iter);

            DatabaseConnection* pConn = dynamic_cast<DatabaseConnection*>(_pConnection.get());

            pConn->onDestroyEvent(_pConnection);
            delete pConn;
        }
        else
        {
            // Not expired, so we are here for no reason
            // We can get here during race conditions where one shared_ptr
            // is being deleted while connect() is being called and connect()
            // beat onDestroy() to the lock(m_pConnectionsGuard).
            return;
        }
    }
    else
    {
        // TODO Severe error, should never get here
    }
}
开发者ID:SgtFlame,项目名称:indiezen,代码行数:35,代码来源:DatabaseService.cpp

示例4: databaseConnectionList

QStringList Project::databaseConnectionList()
{
    QStringList lst;
    for ( DatabaseConnection *conn = dbConnections.first(); conn; conn = dbConnections.next() )
	lst << conn->name();
    return lst;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:7,代码来源:project.cpp

示例5: dbInitialize

void Database::run()
{

    m_initialized = dbInitialize();
	m_condition.notify_one();
	if(!m_initialized)
	{
		return;
	}
	

    Query* q;
    while (!m_shutdown)
    {
        m_queryQueue.popWait(q);
        
        if(m_shutdown && !q)
        {
            // no remaining connection, we can quit the thread
            return;
        }
        
        DatabaseConnection* dbc;
        m_dbConnQueue.popWait(dbc);
        dbc->processQuery(q);
    }
}
开发者ID:vipuldivyanshu92,项目名称:Projects,代码行数:27,代码来源:Database.cpp

示例6: executeSynchronousQuery

bool Database::executeSynchronousQuery(Query* q)
{
	    DatabaseConnection* dbc;
        m_dbConnQueue.popWait(dbc);

		dbc->processSynchronousQuery(q);

		releaseDBConnection(dbc);
		return true;
}
开发者ID:vipuldivyanshu92,项目名称:Projects,代码行数:10,代码来源:Database.cpp

示例7:

DatabaseConnection *Project::databaseConnection( const QString &name )
{
    for ( DatabaseConnection *conn = dbConnections.first();
	  conn;
	  conn = dbConnections.next() ) {
	if ( conn->name() == name )
	    return conn;
    }
    return 0;
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:10,代码来源:project.cpp

示例8:

QPtrList<DesignerDatabase> DesignerProjectImpl::databaseConnections() const
{
    QPtrList<DesignerDatabase> lst;
#ifndef QT_NO_SQL
    QPtrList<DatabaseConnection> conns = project->databaseConnections();
    for ( DatabaseConnection *d = conns.first(); d; d = conns.next() )
	lst.append( d->iFace() );
#endif
    return lst;
}
开发者ID:aroraujjwal,项目名称:qt3,代码行数:10,代码来源:designerappiface.cpp

示例9: removeDatabaseConnection

void Project::removeDatabaseConnection( const QString &c )
{
    for ( DatabaseConnection *conn = dbConnections.first(); conn; conn = dbConnections.next() ) {
	if ( conn->name() == c ) {
	    conn->remove();
	    dbConnections.removeRef( conn );
	    delete conn;
	    return;
	}
    }
}
开发者ID:OS2World,项目名称:LIB-QT3_Toolkit_Vbox,代码行数:11,代码来源:project.cpp

示例10: DatabaseConnection

void Database::addDatabase(Database * db)
{
    if (! db)
        return;

    QString connectionName = db->connectionName();
    if (mDatabaseConnections.contains(connectionName)) {
        DatabaseConnection* dbConnection = mDatabaseConnections.value(connectionName);
        dbConnection->addDatabase(db);
    }
    else {
        mDatabaseConnections.insert(connectionName, new DatabaseConnection(connectionName));
    }
}
开发者ID:fr33mind,项目名称:SMTUC,代码行数:14,代码来源:database.cpp

示例11: dbConnect

SEXP dbConnect(SEXP dbType_sexp,
	       SEXP connection_string_sexp,
	       SEXP user_sexp,
	       SEXP pass_sexp,
	       SEXP host_sexp,
	       SEXP port_sexp,
	       SEXP tty_sexp,
	       SEXP dbName_sexp,
	       SEXP options_sexp) {

  SEXP dbi_conn_sexp;
  DatabaseConnection* conn = NULL;
  const char* dbType = CHAR(STRING_PTR(dbType_sexp)[0]);
  const char* connection_string = (connection_string_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(connection_string_sexp)[0]);
  const char* user = (user_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(user_sexp)[0]);
  const char* pass = (pass_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(pass_sexp)[0]);
  const char* host = (host_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(host_sexp)[0]);
  const char* port = (port_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(port_sexp)[0]);
  const char* tty = (tty_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(tty_sexp)[0]);
  const char* dbName = (dbName_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(dbName_sexp)[0]);
  const char* options = (options_sexp == R_NilValue) ? NULL : CHAR(STRING_PTR(options_sexp)[0]);

  // this test is to check whether the package was compiled with support
  // for this specific dbType
  try {
    conn = DatabaseConnection::init(dbType);
  } catch (DriverNotSupported& e) {
    REprintf("%s\n",e.what());
    return R_NilValue;
  }

  // if we succeed then return a wrapped connection, otherwise return null
  try {
    // if user provides connection_string, then use it, otherwise try traditional args
    if(connection_string) {
      conn->connect(connection_string);
    } else {
      conn->connect(user,pass,host,port,tty,dbName,options);
    }
  } catch(BadDatabaseConnection& e) {
    REprintf("%s\n",e.what());
    return R_NilValue;
  }

  PROTECT(dbi_conn_sexp = R_MakeExternalPtr(reinterpret_cast<void*>(conn),install("DBI_conn_pointer"),R_NilValue));
  R_RegisterCFinalizerEx(dbi_conn_sexp, connFinalizer, TRUE);
  UNPROTECT(1);
  return dbi_conn_sexp;
}
开发者ID:armstrtw,项目名称:unifieddbi,代码行数:49,代码来源:interface.cpp

示例12: dbListTables

SEXP dbListTables(SEXP dbi_conn_sexp) {

 if(TYPEOF(dbi_conn_sexp) != EXTPTRSXP || dbi_conn_sexp == R_NilValue) {
    return R_NilValue;
  }

  DatabaseConnection* conn = reinterpret_cast<DatabaseConnection*>(R_ExternalPtrAddr(dbi_conn_sexp));
  if(!conn) {
    // throw bad_connection_object
    REprintf("bad database connection.\n");
    return R_NilValue;
  }

  return conn->listTables();
}
开发者ID:armstrtw,项目名称:unifieddbi,代码行数:15,代码来源:interface.cpp

示例13: removeDatabase

void Database::removeDatabase(Database * db)
{
    if (! db)
        return;

    QString connectionName = db->connectionName();
    if (mDatabaseConnections.contains(connectionName)) {
        DatabaseConnection* dbConnection = mDatabaseConnections.value(connectionName);
        dbConnection->removeDatabase(db);
        if (! dbConnection->isActive()) {
            mDatabaseConnections.remove(connectionName);
            dbConnection->deleteLater();
        }
    }
}
开发者ID:fr33mind,项目名称:SMTUC,代码行数:15,代码来源:database.cpp

示例14: while

/**
 *
 * Destroys this connection manager
 *
 * @return void
 */
DatabaseConnectionManager::~DatabaseConnectionManager()
{
    DatabaseConnection *connection;
    bool waiting = true;

    while (waiting) {

        // Our default state is not waiting
        waiting = false;

        Connections connections(this->connections);
        for (Connections::const_iterator it = connections.begin();
                it != connections.end(); ++it) {

            connection = it->first;

            if (connection->isStopping()) {

                // Wait for the connection to finish
                connection->join();

                // Remove from collection
                this->connections.erase(connection);

                // Free memory
                if (connection != mainConnection) {
                    delete connection;
                }
            } else {

                // Ask the connection to stop running
                connection->stop(false);

                // This connection may not be finished yet
                waiting = true;
            }
        }
    }

    delete this->mainConnection;

    #ifdef TRACK_POINTERS
    rDebug << "DatabaseConnectionManager::destroy" << this;
    #endif
}
开发者ID:RabidSQL,项目名称:backend,代码行数:51,代码来源:DatabaseConnectionManager.cpp

示例15: dbSendQuery

SEXP dbSendQuery(SEXP dbi_conn_sexp, SEXP qry_sexp) {
  if(TYPEOF(dbi_conn_sexp) != EXTPTRSXP || dbi_conn_sexp == R_NilValue) {
    return R_NilValue;
  }

  SEXP dbi_query_results_sexp;
  DatabaseConnection* conn = reinterpret_cast<DatabaseConnection*>(R_ExternalPtrAddr(dbi_conn_sexp));
  if(!conn) {
    // throw bad_connection_object
    return R_NilValue;
  }
  const char* qry = CHAR(STRING_PTR(qry_sexp)[0]);
  QueryResults* query_results = conn->sendQuery(qry);
  //query_results->getStatus();

  PROTECT(dbi_query_results_sexp = R_MakeExternalPtr(reinterpret_cast<void*>(query_results),install("DBI_results_pointer"),R_NilValue));
  R_RegisterCFinalizerEx(dbi_query_results_sexp, queryResultsFinalizer, TRUE);
  UNPROTECT(1);
  return dbi_query_results_sexp;
}
开发者ID:armstrtw,项目名称:unifieddbi,代码行数:20,代码来源:interface.cpp


注:本文中的DatabaseConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。