21.4.5.1. MySQL Connector/C++ Connecting to MySQL
21.4.5.1. MySQL Connector/C++ Connecting to MySQL
A connection to MySQL is established by retrieving an instance of
sql::Connection
from asql::mysql::MySQL_Driver
object. Asql::mysql::MySQL_Driver
object is returned bysql::mysql::MySQL_Driver::get_mysql_driver_instance()
.sql::mysql::MySQL_Driver *driver; sql::Connection *con; driver = sql::mysql::MySQL_Driver::get_mysql_driver_instance(); con = driver->connect("tcp://127.0.0.1:3306", "user", "password"); delete con;Make sure that you free the
sql::Connection
object as soon as you do not need it any more. But do not explicitly free the connector object!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步