mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-08 21:10:02 +02:00
#310 Connect to MySQL db without specifying database name.
This commit is contained in:
@@ -90,6 +90,27 @@ MySQLTest::~MySQLTest()
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::testConnectNoDB()
|
||||
{
|
||||
std::string dbConnString = "host=" MYSQL_HOST
|
||||
";user=" MYSQL_USER
|
||||
";password=" MYSQL_PWD
|
||||
";compress=true;auto-reconnect=true";
|
||||
|
||||
try
|
||||
{
|
||||
Session session(MySQL::Connector::KEY, dbConnString);
|
||||
std::cout << "Connected to [" << "MySQL" << "] without database. Disconnecting ..." << std::endl;
|
||||
session.close();
|
||||
std::cout << "Disconnected." << std::endl;
|
||||
}
|
||||
catch (ConnectionFailedException& ex)
|
||||
{
|
||||
std::cout << ex.displayText() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MySQLTest::testBareboneMySQL()
|
||||
{
|
||||
if (!_pSession) fail ("Test not available.");
|
||||
@@ -778,6 +799,7 @@ CppUnit::Test* MySQLTest::suite()
|
||||
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTest");
|
||||
|
||||
CppUnit_addTest(pSuite, MySQLTest, testConnectNoDB);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testBareboneMySQL);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testSimpleAccess);
|
||||
CppUnit_addTest(pSuite, MySQLTest, testComplexType);
|
||||
|
@@ -57,6 +57,7 @@ public:
|
||||
MySQLTest(const std::string& name);
|
||||
~MySQLTest();
|
||||
|
||||
void testConnectNoDB();
|
||||
void testBareboneMySQL();
|
||||
|
||||
void testSimpleAccess();
|
||||
|
Reference in New Issue
Block a user