Example #1
0
int pingNode(char *host, char *port)
{
	PGPing status;
	char conninfo[MAXLINE+1];
	char editBuf[MAXPATH+1];

	conninfo[0] = 0;
	if (host)
	{
		snprintf(editBuf, MAXPATH, "host = '%s' ", host);
		strncat(conninfo, editBuf, MAXLINE);
	}
	if (port)
	{
		snprintf(editBuf, MAXPATH, "port = %d ", atoi(port));
		strncat(conninfo, editBuf, MAXLINE);
	}
	if (conninfo[0])
	{
		status = PQping(conninfo);
		if (status == PQPING_OK)
			return 0;
		else
			return 1;
	}
	else
		return -1;
}
void Database_PostgreSQL::ping()
{
	if (PQping(m_connect_string.c_str()) != PQPING_OK) {
		throw DatabaseException(std::string(
			"PostgreSQL database error: ") +
			PQerrorMessage(m_conn));
	}
}
Example #3
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::CheckConnection(const AString& host)
{
	AString connstr;

	connstr.printf("postgresql://%s", host.str());

	bool success = (PQping(connstr) == PQPING_OK);
	debug("Checking connection to %s...%s\n", host.str(), success ? "success" : "**failure**");
	return success;
}
Example #4
0
/*--------------------------------------------------------------------------------*/
bool PostgresDatabase::CheckConnection()
{
	bool success = (PQping(connstr) == PQPING_OK);
	debug("Checking connection...%s\n", success ? "success" : "**failure**");
	return success;
}