• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PQsetdbLogin函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: InitDelayThread

bool DatabasePostgre::Initialize(const char *infoString)
{
    if(!Database::Initialize(infoString))
        return false;

    tranThread = NULL;

    InitDelayThread();

    Tokens tokens = StrSplit(infoString, ";");

    Tokens::iterator iter;

    std::string host, port_or_socket_dir, user, password, database;

    iter = tokens.begin();

    if(iter != tokens.end())
        host = *iter++;
    if(iter != tokens.end())
        port_or_socket_dir = *iter++;
    if(iter != tokens.end())
        user = *iter++;
    if(iter != tokens.end())
        password = *iter++;
    if(iter != tokens.end())
        database = *iter++;

    if (host == ".")
        mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
    else
        mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());

    /* check to see that the backend connection was successfully made */
    if (PQstatus(mPGconn) != CONNECTION_OK)
    {
        sLog.outError( "Could not connect to Postgre database at %s: %s",
            host.c_str(), PQerrorMessage(mPGconn));
        PQfinish(mPGconn);
        mPGconn = NULL;
        return false;
    }
    else
    {
        sLog.outDetail( "Connected to Postgre database at %s",
            host.c_str());
        sLog.outString( "PostgreSQL server ver: %d",PQserverVersion(mPGconn));
        return true;
    }

}
开发者ID:Scergo,项目名称:zero,代码行数:51,代码来源:DatabasePostgre.cpp


示例2: STAFF_ASSERT

  void PostgresProvider::Init(const xml::Element& rConfig)
  {
    // initialize connection
    const xml::Element& rConnection = rConfig.GetChildElementByName("connection");

    m_pImpl->m_sHost = rConnection.GetChildElementByName("host").GetTextValue();
    m_pImpl->m_sPort = rConnection.GetChildElementByName("port").GetTextValue();
    m_pImpl->m_sDataBase = rConnection.GetChildElementByName("db").GetTextValue();
    m_pImpl->m_sLogin = rConnection.GetChildElementByName("login").GetTextValue();
    m_pImpl->m_sPassword = rConnection.GetChildElementByName("password").GetTextValue();

    STAFF_ASSERT(!m_pImpl->m_pConn, "Already connected");
    m_pImpl->m_pConn = PQsetdbLogin(m_pImpl->m_sHost.c_str(), m_pImpl->m_sPort.c_str(), "", "",
                                    m_pImpl->m_sDataBase.c_str(), m_pImpl->m_sLogin.c_str(),
                                    m_pImpl->m_sPassword.c_str());

    STAFF_ASSERT(m_pImpl->m_pConn, "Failed to set db login");
    if (PQstatus(m_pImpl->m_pConn) != CONNECTION_OK)
    {
      std::string sError = std::string("Failed to login: ") + PQerrorMessage(m_pImpl->m_pConn);
      PQfinish(m_pImpl->m_pConn);
      m_pImpl->m_pConn = NULL;
      STAFF_THROW_ASSERT(sError);
    }

    int nResult = PQsetClientEncoding(m_pImpl->m_pConn, "UTF8");
    STAFF_ASSERT(nResult == 0, std::string("error setting encoding: ") + PQerrorMessage(m_pImpl->m_pConn));
  }
开发者ID:AmesianX,项目名称:staff,代码行数:28,代码来源:Postgres.cpp


示例3: sql_conn

/* establish connection with database. */
PGconn *
sql_conn(struct options * my_opts)
{
	PGconn	   *conn;

	/* login */
	conn = PQsetdbLogin(my_opts->hostname,
						my_opts->port,
						NULL,	/* options */
						NULL,	/* tty */
						my_opts->dbname,
						my_opts->username,
						my_opts->password);

	/* deal with errors */
	if (PQstatus(conn) != CONNECTION_OK)
	{
		fprintf(stderr, "%s: connection to database '%s' failed.\n", "oid2name", my_opts->dbname);
		fprintf(stderr, "%s", PQerrorMessage(conn));

		PQfinish(conn);
		exit(1);
	}

	/* return the conn if good */
	return conn;
}
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:28,代码来源:oid2name.c


示例4: PQsetdbLogin

/** 
 * Connect to Postgres with the current settings through libpq.
 *
 * @author    Martin Turon
 *
 * @return    Error code from Postgres after executing command
 *
 * @version   2004/8/8       mturon      Initial version
 *
 */
PGconn *xdb_connect() 
{
     char       *pgoptions, *pgtty;
     PGconn     *conn;
 
     /*
      * begin, by setting the parameters for a backend connection if the
      * parameters are null, then the system will try to use reasonable
      * defaults by looking up environment variables or, failing that,
      * using hardwired constants
      */
     pgoptions = NULL;           /* special options to start up the backend
                                  * server */
     pgtty = NULL;               /* debugging tty for the backend server */
 
     /* make a connection to the database */
     conn = PQsetdbLogin(g_server, g_port, pgoptions, pgtty, 
			 g_dbname, g_user, g_passwd);
     /*
      * check to see that the backend connection was successfully made
      */
     if (PQstatus(conn) == CONNECTION_BAD)
     {
         fprintf(stderr, "error: Connection to database '%s' failed.\n", 
		 g_dbname);
         fprintf(stderr, "%s", PQerrorMessage(conn));
         conn = xdb_exit(conn);
     }
     
     return conn;
}
开发者ID:ekiwi,项目名称:tinyos-1.x,代码行数:41,代码来源:xdb.c


示例5: pgconn_create

PGConnection *
pgconn_create(const char *host, const char *db, const char *user, const char *password)
{
   PGConnection *conn;

   if (db == NULL)
      THROW("SQLException", "Database may not be (null)");

   conn = emalloc(sizeof(PGConnection));
   conn->stream = PQsetdbLogin(host,"5432",NULL,NULL,db,user,password);

   if (PQstatus(conn->stream) != CONNECTION_OK)
      THROW("SQLException", "%s", PQerrorMessage(conn->stream));

   if(pgTypes == NULL){
      PGResultSet *rset = pgconn_query(conn, "SELECT oid,typname FROM pg_type");
      pgTypes = ihtab_createDefault();

      while(pgrset_next(rset)){
        ihtab_put(pgTypes, pgrset_getInt(rset, 0), pgrset_getString(rset, 1));
      }
   }
   
   return conn;
}
开发者ID:berkus,项目名称:moto,代码行数:25,代码来源:pgconn.c


示例6: db_init_pg_conn

void db_init_pg_conn(const char *conf_file) {
  if(config_read_file(&config, conf_file) != CONFIG_TRUE) {
    fprintf(stderr, "%s:%d %s\n", config_error_file(&config), config_error_line(&config), config_error_text(&config));
    config_destroy(&config);
    exit(EXIT_FAILURE);
  }

  conn = PQsetdbLogin(
    read_db_setting("db_host"),
    read_db_setting("db_port"),
    NULL, NULL,
    read_db_setting("db_name"),
    read_db_setting("db_login"),
    read_db_setting("db_password"));

  const char *store_dir_tmp = read_db_setting("store_dir");
  store_dir = (char*)malloc(strlen(store_dir_tmp)+1);
  strcpy(store_dir, store_dir_tmp);

  if(PQstatus(conn) != CONNECTION_OK) {
    fprintf(stderr, "Connection to database failed: %s\n", PQerrorMessage(conn));
    config_destroy(&config);
    exit(EXIT_FAILURE);
  } else {
    fprintf(stderr, "database OK\n");
  }

  if(pthread_mutex_init(&db_lock, NULL) < 0) {
    fprintf(stderr, "pthread_mutex_init failed\n");
    exit(EXIT_FAILURE);
  }
}
开发者ID:sanek701,项目名称:CCTV-linux-msiu,代码行数:32,代码来源:database.c


示例7: switch_database

static int
switch_database(struct dbpath *dbpath)
{
	PGconn *newdbconn;

	if (dbpath_is_root(*dbpath))
		return 1;

	if (strcmp(dbpath->database, PQdb(dbconn)) == 0)
		return 1;

	newdbconn = PQsetdbLogin(PQhost(dbconn),
							 PQport(dbconn),
							 PQoptions(dbconn),
							 PQtty(dbconn),
							 dbpath->database,
							 PQuser(dbconn),
							 PQpass(dbconn));

	if (PQstatus(newdbconn) != CONNECTION_OK)
	{
		debug("new connection failed");
		PQfinish(newdbconn);
		return 0;
	}

	PQfinish(dbconn);
	dbconn = newdbconn;
	return 1;
}
开发者ID:GunioRobot,项目名称:postgresqlfs,代码行数:30,代码来源:postgresqlfs.c


示例8: quorra_db_object_initConnection

gboolean quorra_db_object_initConnection(QuorraDbObject * obj,
										gchar * pghost,
										gchar * pgport,
										gchar * dbName,
										gchar * login,
										gchar * pwd)
{
	QuorraDbObjectPrivate * priv;

	if (dbName == NULL)
	{
		g_warning("Connection to database failed: database isn't set!");
		return FALSE;
	}

	priv = QUORRA_DBOBJ_GET_PRIVATE (obj);
	if (priv)
	{
		priv->connection = PQsetdbLogin(pghost,pgport,NULL,NULL,dbName,login,pwd);

		/* Check to see that the backend connection was successfully made */
		if (PQstatus(priv->connection) != CONNECTION_OK)
		{
			g_warning("Connection to database failed: %s", PQerrorMessage(priv->connection));
		    PQfinish(priv->connection);
			return FALSE;
		}
		return TRUE;
	}
	return FALSE;
}
开发者ID:bozzo,项目名称:Quorra,代码行数:31,代码来源:QuorraDbObject.c


示例9: pgsqlConnect

static HB_ERRCODE pgsqlConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   PGconn *       pConn;
   ConnStatusType status;
   const char *   pszHost;

   pszHost = hb_arrayGetCPtr( pItem, 2 );
   if( pszHost && ( strncmp( pszHost, "postgresql://", 13 ) == 0 || strchr( pszHost, '=' ) ) )
      pConn = PQconnectdb( pszHost );
   else
      pConn = PQsetdbLogin( pszHost, hb_arrayGetCPtr( pItem, 6 ), hb_arrayGetCPtr( pItem, 7 ), hb_arrayGetCPtr( pItem, 8 ), hb_arrayGetCPtr( pItem, 5 ), hb_arrayGetCPtr( pItem, 3 ), hb_arrayGetCPtr( pItem, 4 ) );

   if( ! pConn )   /* Low memory, etc */
   {
      /* TODO: error */
      return HB_FAILURE;
   }
   status = PQstatus( pConn );
   if( status != CONNECTION_OK )
   {
      /* TODO: error */
      PQfinish( pConn );
      return HB_FAILURE;
   }
   pConnection->pSDDConn = hb_xgrab( sizeof( SDDCONN ) );
   ( ( SDDCONN * ) pConnection->pSDDConn )->pConn = pConn;
   return HB_SUCCESS;
}
开发者ID:AmericoBalboa,项目名称:core,代码行数:28,代码来源:core.c


示例10: PQreset

void PostgreSQLConnection::connect()
{
	bool reconnecting = false;
	if (_pgConn != nullptr) //reconnection attempt
	{
		if (!_ConnectionLost())
			return;
		else
			reconnecting = true;
	}

	//remove any state from previous session
	this->clear();

	Poco::Logger& logger = _dbEngine->getLogger();
	for(;;)
	{
		if (reconnecting)
			PQreset(_pgConn);
		else
		{
			if (_host == ".")
				_pgConn = PQsetdbLogin(nullptr, _port == "." ? nullptr : _port.c_str(), nullptr, nullptr, _database.c_str(), _user.c_str(), _password.c_str());
			else
				_pgConn = PQsetdbLogin(_host.c_str(), _port.c_str(), nullptr, nullptr, _database.c_str(), _user.c_str(), _password.c_str());
		}
		
		//check to see that the backend connection was successfully made
		if (_ConnectionLost())
		{
			const char* actionToDo = "connect";
			if (reconnecting)
				actionToDo = "reconnect";

			static const long sleepTime = 1000;
			logger.warning(Poco::format("Could not %s to Postgre database at %s: %s, retrying in %d seconds",
				string(actionToDo),_host,lastErrorDescr(),static_cast<int>(sleepTime/1000)));
			Poco::Thread::sleep(sleepTime);

			continue;
		}
		break;
	}

	string actionDone = (reconnecting)?string("Reconnected"):string("Connected");
	poco_information(logger,Poco::format("%s to Postgre database %s:%s/%s server ver: %d",actionDone,_host,_port,_database,PQserverVersion(_pgConn)));
}
开发者ID:AlexSpain,项目名称:hive,代码行数:47,代码来源:DatabasePostgre.cpp


示例11: main

int
main (int argc, char **argv)
{
	int elapsed_time;
	int status = STATE_UNKNOWN;

	/* begin, by setting the parameters for a backend connection if the
	 * parameters are null, then the system will try to use reasonable
	 * defaults by looking up environment variables or, failing that,
	 * using hardwired constants */

	pgoptions = NULL;  /* special options to start up the backend server */
	pgtty = NULL;      /* debugging tty for the backend server */

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	/* Set signal handling and alarm */
	if (signal (SIGALRM, timeout_alarm_handler) == SIG_ERR) {
		usage4 (_("Cannot catch SIGALRM"));
	}
	alarm (timeout_interval);

	/* make a connection to the database */
	time (&start_time);
	conn =
		PQsetdbLogin (pghost, pgport, pgoptions, pgtty, dbName, pguser, pgpasswd);
	time (&end_time);
	elapsed_time = (int) (end_time - start_time);

	/* check to see that the backend connection was successfully made */
	if (PQstatus (conn) == CONNECTION_BAD) {
		printf (_("CRITICAL - no connection to '%s' (%s).\n"),
		        dbName,	PQerrorMessage (conn));
		PQfinish (conn);
		return STATE_CRITICAL;
	}
	else if (elapsed_time > tcrit) {
		status = STATE_CRITICAL;
	}
	else if (elapsed_time > twarn) {
		status = STATE_WARNING;
	}
	else {
		status = STATE_OK;
	}
	PQfinish (conn);
	printf (_(" %s - database %s (%d sec.)|%s\n"), 
	        state_text(status), dbName, elapsed_time,
	        fperfdata("time", elapsed_time, "s",
	                 (int)twarn, twarn, (int)tcrit, tcrit, TRUE, 0, FALSE,0));
	return status;
}
开发者ID:rmoorman,项目名称:build,代码行数:57,代码来源:check_pgsql.c


示例12: db_connect

/*
 * Connect to the database.
 */
static isc_result_t db_connect (struct dbinfo *dbi)
{
    dbi->conn = PQsetdbLogin (dbi->host, NULL, NULL, NULL, dbi->database, dbi->user, dbi->passwd);

    if (PQstatus (dbi->conn) == CONNECTION_OK)
        return (ISC_R_SUCCESS);
    else
        return (ISC_R_FAILURE);
}
开发者ID:274914765,项目名称:C,代码行数:12,代码来源:pgsqldb.c


示例13: db_postgres_new_connection

/*!
 * \brief Create a new connection
 *
 * Create a new connection structure in private memory, open the PostgreSQL
 * connection and set reference count to 1
 * \param id database id
 * \return postgres connection structure, 0 on error
 */
struct pg_con* db_postgres_new_connection(struct db_id* id)
{
	struct pg_con* ptr;
	char *ports;

	LM_DBG("db_id = %p\n", id);
 
	if (!id) {
		LM_ERR("invalid db_id parameter value\n");
		return 0;
	}

	ptr = (struct pg_con*)pkg_malloc(sizeof(struct pg_con));
	if (!ptr) {
		LM_ERR("failed trying to allocated %lu bytes for connection structure."
				"\n", (unsigned long)sizeof(struct pg_con));
		return 0;
	}
	LM_DBG("%p=pkg_malloc(%lu)\n", ptr, (unsigned long)sizeof(struct pg_con));

	memset(ptr, 0, sizeof(struct pg_con));
	ptr->ref = 1;

	if (id->port) {
		ports = int2str(id->port, 0);
		LM_DBG("opening connection: postgres://xxxx:[email protected]%s:%d/%s\n", ZSW(id->host),
			id->port, ZSW(id->database));
	} else {
		ports = NULL;
		LM_DBG("opening connection: postgres://xxxx:[email protected]%s/%s\n", ZSW(id->host),
			ZSW(id->database));
	}

 	ptr->con = PQsetdbLogin(id->host, ports, NULL, NULL, id->database, id->username, id->password);
	LM_DBG("PQsetdbLogin(%p)\n", ptr->con);

	if( (ptr->con == 0) || (PQstatus(ptr->con) != CONNECTION_OK) )
	{
		LM_ERR("%s\n", PQerrorMessage(ptr->con));
		PQfinish(ptr->con);
		goto err;
	}

	ptr->connected = 1;
	ptr->timestamp = time(0);
	ptr->id = id;

	return ptr;

 err:
	if (ptr) {
		LM_ERR("cleaning up %p=pkg_free()\n", ptr);
		pkg_free(ptr);
	}
	return 0;
}
开发者ID:mehulsbhatt,项目名称:voip-foip,代码行数:64,代码来源:km_pg_con.c


示例14: _log

void *be_pg_init()
{
	struct pg_backend *conf;
	char *host, *user, *pass, *dbname, *p, *port;
	char *userquery;

	_log(LOG_DEBUG, "}}}} POSTGRES");

	host   = p_stab("host");
	p      = p_stab("port");
	user   = p_stab("user");
	pass   = p_stab("pass");
	dbname = p_stab("dbname");

	host = (host) ? host : strdup("localhost");
	port = (p) ? p : strdup("5432");

	userquery = p_stab("userquery");

	if (!userquery) {
		_fatal("Mandatory option 'userquery' is missing");
		return (NULL);
	}

	if ((conf = (struct pg_backend *)malloc(sizeof(struct pg_backend))) == NULL)
		return (NULL);

	conf->conn       = NULL;
	conf->host       = host;
	conf->port       = port;
	conf->user       = user;
	conf->pass       = pass;
	conf->dbname     = dbname;
	conf->userquery  = userquery;
	conf->superquery = p_stab("superquery");
	conf->aclquery   = p_stab("aclquery");

	_log( LOG_DEBUG, "HERE: %s", conf->superquery );
	_log( LOG_DEBUG, "HERE: %s", conf->aclquery );


	char *connect_string = NULL;

	conf->conn = PQsetdbLogin(conf->host, conf->port, NULL, NULL, conf->dbname, conf->user, conf->pass );

	if (PQstatus(conf->conn) == CONNECTION_BAD) {
		free(conf);
		free(connect_string);
		_fatal("We were unable to connect to the database");
		return (NULL);
	}

	free(connect_string);

	return ((void *)conf);
}
开发者ID:Aquevix,项目名称:mosquitto-auth-plug,代码行数:56,代码来源:be-postgres.c


示例15: main

int main()
{
	Conn_pointer=PQsetdbLogin(pghost, pgport, pgoptions, pgtty, dbName, username, password);
	if (PQstatus(Conn_pointer) == CONNECTION_BAD)
	{
		printf("cannot connect to the database!\n");
		return -1;
	}
	printf ("Connect to database seccess\n");
	return 0;
}
开发者ID:Berimor66,项目名称:osgis,代码行数:11,代码来源:pg90.c


示例16: print_info

PGconn *make_connection(database_settings *db) {
  PGconn *conn = NULL;
  print_info("Trying to connect to database.\n");
  conn = PQsetdbLogin(db->host, db->port, NULL, NULL, db->name, db->user,
      db->pass);
  if (PQstatus(conn) != CONNECTION_OK) {
    fprintf(stderr, "Error connecting to database.\n");
    exit(-1);
  }
  print_info("Successfully connected to database.\n");
  return conn;
}
开发者ID:justjkk,项目名称:gtfs2pgrouting,代码行数:12,代码来源:sql_utils.c


示例17: pq_setdb

/* ML type : 6-element record -> pgconn_ */
EXTERNML value pq_setdb(value args) 
{
  char* dbhost    = StringOrNull_val(Field(args, 0));
  char* dbname    = StringOrNull_val(Field(args, 1));
  char* dboptions = StringOrNull_val(Field(args, 2));
  char* dbport    = StringOrNull_val(Field(args, 3));
  char* dbpwd     = StringOrNull_val(Field(args, 4));
  char* dbtty     = StringOrNull_val(Field(args, 5));
  char* dbuser    = StringOrNull_val(Field(args, 6));
  return (value)(pgconn_alloc(PQsetdbLogin(dbhost, dbport, dboptions, dbtty, 
					   dbname, dbuser, dbpwd)));
}
开发者ID:Athas,项目名称:mosml,代码行数:13,代码来源:mpq.c


示例18: sql_conn

/* establish connection with database. */
PGconn *
sql_conn(struct options * my_opts)
{
	PGconn	   *conn;
	char	   *password = NULL;
	bool		new_pass;

	/*
	 * Start the connection.  Loop until we have a password if requested by
	 * backend.
	 */
	do
	{
		new_pass = false;
		conn = PQsetdbLogin(my_opts->hostname,
							my_opts->port,
							NULL,		/* options */
							NULL,		/* tty */
							my_opts->dbname,
							my_opts->username,
							password);
		if (!conn)
		{
			fprintf(stderr, "%s: could not connect to database %s\n",
					"oid2name", my_opts->dbname);
			exit(1);
		}

		if (PQstatus(conn) == CONNECTION_BAD &&
			PQconnectionNeedsPassword(conn) &&
			password == NULL)
		{
			PQfinish(conn);
			password = simple_prompt("Password: ", 100, false);
			new_pass = true;
		}
	} while (new_pass);

	if (password)
		free(password);

	/* check to see that the backend connection was successfully made */
	if (PQstatus(conn) == CONNECTION_BAD)
	{
		fprintf(stderr, "%s: could not connect to database %s: %s",
				"oid2name", my_opts->dbname, PQerrorMessage(conn));
		PQfinish(conn);
		exit(1);
	}

	/* return the conn if good */
	return conn;
}
开发者ID:CadillacBupt,项目名称:recdb-postgresql,代码行数:54,代码来源:oid2name.c


示例19: connectDatabase

/*
 * Make a database connection with the given parameters.  An
 * interactive password prompt is automatically issued if required.
 */
PGconn *
connectDatabase(const char *dbname, const char *pghost, const char *pgport,
				const char *pguser, enum trivalue prompt_password,
				const char *progname)
{
	PGconn	   *conn;
	char	   *password = NULL;
	bool		new_pass;

	if (prompt_password == TRI_YES)
		password = simple_prompt("Password: ", 100, false);

	/*
	 * Start the connection.  Loop until we have a password if requested by
	 * backend.
	 */
	do
	{
		new_pass = false;
		conn = PQsetdbLogin(pghost, pgport, NULL, NULL, dbname, pguser, password);

		if (!conn)
		{
			fprintf(stderr, _("%s: could not connect to database %s\n"),
					progname, dbname);
			exit(1);
		}

		if (PQstatus(conn) == CONNECTION_BAD &&
			PQconnectionNeedsPassword(conn) &&
			password == NULL &&
			prompt_password != TRI_NO)
		{
			PQfinish(conn);
			password = simple_prompt("Password: ", 100, false);
			new_pass = true;
		}
	} while (new_pass);

	if (password)
		free(password);

	/* check to see that the backend connection was successfully made */
	if (PQstatus(conn) == CONNECTION_BAD)
	{
		fprintf(stderr, _("%s: could not connect to database %s: %s"),
				progname, dbname, PQerrorMessage(conn));
		exit(1);
	}

	return conn;
}
开发者ID:Aldizh,项目名称:buffer_manager,代码行数:56,代码来源:common.c


示例20: PQsetdbLogin

int PGDatabase::Connect( const PGConnInfo& dbConnInfo ) {
	m_pConnect= PQsetdbLogin(dbConnInfo.pghost, dbConnInfo.pgport,
		"", "", dbConnInfo.dbName, 
		dbConnInfo.login, dbConnInfo.passwd);
	if (PQstatus(m_pConnect) != CONNECTION_OK) {
		fprintf(stderr, "Connection to database failed: %s",
			PQerrorMessage(m_pConnect));
	    PQfinish(m_pConnect);

		return 1;
	}

	return 0;
}
开发者ID:GisKook,项目名称:ThirdPart,代码行数:14,代码来源:PGDatabase.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PQsocket函数代码示例发布时间:2022-05-30
下一篇:
C++ PQserverVersion函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap