Spec-Zone .ru
спецификации, руководства, описания, API
|
For running simple queries, you can use the methods sql::Statement::execute()
,
sql::Statement::executeQuery()
and sql::Statement::executeUpdate()
.
Use the method sql::Statement::execute()
if your query does not return a result
set or if your query returns more than one result set. See the examples/
directory
for more information.
sql::mysql::MySQL_Driver *driver;sql::Connection *con;sql::Statement *stmt;driver = sql::mysql::get_mysql_driver_instance();con = driver->connect("tcp://127.0.0.1:3306", "user", "password");stmt = con->createStatement();stmt->execute("USE " EXAMPLE_DB);stmt->execute("DROP TABLE IF EXISTS test");stmt->execute("CREATE TABLE test(id INT, label CHAR(1))");stmt->execute("INSERT INTO test(id, label) VALUES (1, 'a')");delete stmt;delete con;
Note that you must free sql::Statement
and sql::Connection
objects explicitly using delete
.