weird - mysql's sql::SQLException is not caught by its type, but is caught as std::exception and cast back successfully

后端 未结 1 1957
北荒
北荒 2021-01-16 01:39

I am using mysql c++ connector with this (a bit simplified) code.

try
{
    statement->setString(1, word);
    statement->executeUpdate();
}
catch( sql         


        
相关标签:
1条回答
  • 2021-01-16 02:16

    See the note for dynamic_cast, throw, typeid don't work with shared libraries on the GCC Frequently Asked Questions page.

    Because you are using dlopen(), you need to link your executable with the -E flag (or pass
    -Wl,-E to g++ if g++ is invoking the linker) and pass the RTLD_GLOBAL flag to dlopen().

    0 讨论(0)
提交回复
热议问题