Warning, file /sdk/codevis/thirdparty/soci/examples/subdir-include/subdir-include.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #include <soci/soci.h> 0002 #include <soci/empty/soci-empty.h> 0003 0004 #include <cstdlib> 0005 #include <iostream> 0006 #include <stdexcept> 0007 #include <string> 0008 0009 int main(int argc, char* argv[]) 0010 { 0011 if (argc != 2) 0012 { 0013 std::cerr << "usage: " << argv[0] << " <connection-string>\n"; 0014 return EXIT_FAILURE; 0015 } 0016 0017 std::string connectString{argv[1]}; 0018 0019 try 0020 { 0021 soci::session sql(soci::empty, connectString); 0022 0023 std::cout << "Successfully connected to \"" << connectString << "\", " 0024 << "using \"" << sql.get_backend_name() << "\" backend.\n"; 0025 0026 return EXIT_SUCCESS; 0027 } 0028 catch (const soci::soci_error& e) 0029 { 0030 std::cerr << "Connection to \"" << connectString << "\" failed: " 0031 << e.what() << "\n"; 0032 } 0033 catch (const std::runtime_error& e) 0034 { 0035 std::cerr << "Unexpected standard exception occurred: " 0036 << e.what() << "\n"; 0037 } 0038 catch (...) 0039 { 0040 std::cerr << "Unexpected unknown exception occurred.\n"; 0041 } 0042 0043 return EXIT_FAILURE; 0044 }