#include #include "mysql.h" #define SELECT1 "select a from t where b = ?" int main() { MYSQL *conn; MYSQL_STMT *stmt; MYSQL_RES *meta; MYSQL_FIELD *field; MYSQL_BIND bind; int res; unsigned long len; char buf[21] = {0}; double d=-1.0; conn= mysql_init(NULL); conn= mysql_real_connect(conn, "127.0.0.1", "root", "", "test", 3306, 0, 0); if (!conn) { fprintf(stderr, "Cannot connect\n"); exit(1); } printf("Client info: %s\n", mysql_get_client_info()); printf("Server info: %s\n", mysql_get_server_info(conn)); stmt= mysql_stmt_init(conn); res= mysql_stmt_prepare(stmt, SELECT1, strlen(SELECT1)); meta= mysql_stmt_result_metadata(stmt); memset(&bind, 0, sizeof(bind)); mysql_stmt_bind_param(stmt, &bind); mysql_stmt_execute(stmt); mysql_free_result(meta); mysql_close(conn); return 0; }