MySQL Forums
Forum List  »  Connector/C++

std::bad_alloc thrown on attemt to setSchema
Posted by: Doug Livesey
Date: June 11, 2016 06:31PM

Hi -- I have this really simple code:

auto mysql_driver = get_driver_instance();
sql::Connection *c = mysql_driver->connect("", "root", "tooth");
delete c;

That is generating this error:

terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc

The following command however works in the terminal:
$ mysql -h -u root -ptooth mysql

If I comment out the line with the call to setSchema() in it, no error is thrown, so it looks like the first attempt to (presumably lazy-) use the connection is causing the error.

I'm on linux, and installed Connector/C++ from the tar file.

Could anybody please advise me on what is going wrong, here? I've been trying to fix this for hours, now, but to no avail.
Thanks in advance for any & all assistance,

Options: ReplyQuote

Written By
std::bad_alloc thrown on attemt to setSchema
June 11, 2016 06:31PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.