예제 #1
0
void test3()
{
    DBMysqlConnectionPool pool("mysql://*****:*****@localhost:3306/test");
    if (!pool.init())
        return;

    DBConnection* conn = pool.get(DBCS_PREPARING);
    if (!conn)
        return;

    DBObject14 a;
    if (!conn->prepare("select *,unix_timestamp(t) from test", a))
    {
        while (!conn->next())
        {
            //printf("a.m.size(): %lu\n", a.m.size());
            //printf("a.n.rsize(): %d\n", a.n.rsize());
            printf("%lu,%d,%d,%d,%d,%d,%d,%lld,%lld,%f,%f,%f,%s,%s(%d)\n", a.tt,a.c,a.d,a.e,a.f,a.g,a.h,a.i,a.j,a.k,a.kk,a.l,&a.m[0],a.n.rbuf(),a.n.rsize());
        }
    }

    printf("---------------------------------\n");
#if 1
    conn->finish();
    DBObject14 b;
    if (!conn->prepare("select *,unix_timestamp(t) from test", b))
    {
        while (!conn->next())
        {
            printf("%lu,%d,%d,%d,%d,%d,%d,%lld,%lld,%f,%f,%f,%s,%s(%d)\n", b.tt,b.c,b.d,b.e,b.f,b.g,b.h,b.i,b.j,b.k,b.kk,b.l,&b.m[0],b.n.rbuf(),b.n.rsize());
        }
    }
#endif

    conn->finish();
    pool.put(conn);


}
예제 #2
0
void test2()
{
    DBMysqlConnectionPool pool("mysql://*****:*****@localhost:3306/test");
    //DBMysqlConnectionPool pool("mysql://*****:*****@172.16.5.1:3306/test");
    if (!pool.init())
        return;

    DBConnection* conn = pool.get(DBCS_PREPARING);
    if (!conn)
        return;

    DBObject a;
    //conn->prepare("select * from one", a);
    conn->prepare("select * from one", a);
    while (!conn->next())
    {
        printf("%d\n", a.c);
    }

    printf("---------------------------------\n");
    pool.put(conn);
}