MySQL DateTime support, samples Linux compile

This commit is contained in:
aleks-f
2012-12-14 19:48:10 -06:00
parent 245dc64c7e
commit 2a81e59e8c
19 changed files with 6905 additions and 14 deletions

View File

@@ -35,6 +35,7 @@
#include "Poco/String.h"
#include "Poco/Format.h"
#include "Poco/Tuple.h"
#include "Poco/DateTime.h"
#include "Poco/Any.h"
#include "Poco/Exception.h"
#include "Poco/Data/LOB.h"
@@ -58,6 +59,7 @@ using Poco::Data::MySQL::ConnectionException;
using Poco::Data::MySQL::StatementException;
using Poco::format;
using Poco::Tuple;
using Poco::DateTime;
using Poco::Any;
using Poco::AnyCast;
using Poco::NotFoundException;
@@ -1295,6 +1297,35 @@ void SQLExecutor::blob(int bigSize)
assert (res == big);
}
void SQLExecutor::dateTime()
{
std::string funct = "dateTime()";
std::string lastName("Bart");
std::string firstName("Simpson");
std::string address("Springfield");
DateTime birthday(1980, 4, 1, 5, 45, 12);
int count = 0;
try { *_pSession << "INSERT INTO Person VALUES (?,?,?,?)", use(lastName), use(firstName), use(address), use(birthday), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
try { *_pSession << "SELECT COUNT(*) FROM Person", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assert (count == 1);
DateTime bd;
assert (bd != birthday);
try { *_pSession << "SELECT Birthday FROM Person", into(bd), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assert (bd == birthday);
std::cout << std::endl << RecordSet(*_pSession, "SELECT * FROM Person");
}
void SQLExecutor::blobStmt()
{
std::string funct = "blobStmt()";
@@ -1320,6 +1351,7 @@ void SQLExecutor::blobStmt()
poco_assert (res == blob);
}
void SQLExecutor::tuples()
{
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;
@@ -1338,6 +1370,7 @@ void SQLExecutor::tuples()
assert (ret == t);
}
void SQLExecutor::tupleVector()
{
typedef Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> TupleType;