File: subdir-include.cpp

package info (click to toggle)
soci 4.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,944 kB
  • sloc: ansic: 169,887; cpp: 54,198; javascript: 12,258; ada: 1,973; sh: 36; makefile: 12; xml: 2
file content (44 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <soci/soci.h>
#include <soci/empty/soci-empty.h>

#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>

int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        std::cerr << "usage: " << argv[0] << " <connection-string>\n";
        return EXIT_FAILURE;
    }

    std::string connectString{argv[1]};

    try
    {
        soci::session sql(soci::empty, connectString);

        std::cout << "Successfully connected to \"" << connectString << "\", "
                  << "using \"" << sql.get_backend_name() << "\" backend.\n";

        return EXIT_SUCCESS;
    }
    catch (const soci::soci_error& e)
    {
        std::cerr << "Connection to \"" << connectString << "\" failed: "
                  << e.what() << "\n";
    }
    catch (const std::runtime_error& e)
    {
        std::cerr << "Unexpected standard exception occurred: "
                  << e.what() << "\n";
    }
    catch (...)
    {
        std::cerr << "Unexpected unknown exception occurred.\n";
    }

    return EXIT_FAILURE;
}