~mysql/mysql-connector-cpp/trunk

« back to all changes in this revision

Viewing changes to examples/debug_output.cpp

  • Committer: Hemant Dangi
  • Date: 2014-12-17 16:28:39 UTC
  • Revision ID: hemant.dangi@oracle.com-20141217162839-sdbpj3fcwn5gxjxh
Bug #75251: Add C++11 support and replace (deprecated in C++11) auto_ptr

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
 
2
Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
3
3
 
4
4
The MySQL Connector/C++ is licensed under the terms of the GPLv2
5
5
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
81
81
#include <sstream>
82
82
#include <stdexcept>
83
83
 
 
84
#include <boost/scoped_ptr.hpp>
 
85
 
84
86
/* Public interface of the MySQL Connector/C++ */
85
87
#include <driver/mysql_public_iface.h>
86
88
/* Connection parameter and sample data */
106
108
        try {
107
109
                /* Using the Driver to create a connection */
108
110
                driver = sql::mysql::get_driver_instance();
109
 
                std::auto_ptr< sql::Connection > con(driver->connect(host, user, pass));
 
111
                boost::scoped_ptr< sql::Connection > con(driver->connect(host, user, pass));
110
112
 
111
113
                /*
112
114
                 Activate debug trace of the MySQL Client Library (C-API)
116
118
 
117
119
                con->setSchema(database);
118
120
 
119
 
                std::auto_ptr< sql::Statement > stmt(con->createStatement());
 
121
                boost::scoped_ptr< sql::Statement > stmt(con->createStatement());
120
122
                stmt->execute("DROP TABLE IF EXISTS test");
121
123
                stmt->execute("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label CHAR(1))");
122
124
                cout << "#\t Test table created" << endl;
123
125
 
124
 
                std::auto_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)"));
 
126
                boost::scoped_ptr< sql::PreparedStatement > prep_stmt(con->prepareStatement("INSERT INTO test(id, label) VALUES (?, ?)"));
125
127
                for (i = 0; i < EXAMPLE_NUM_TEST_ROWS; i++) {
126
128
                        prep_stmt->setInt(1, test_data[i].id);
127
129
                        prep_stmt->setString(2, test_data[i].label);