[96975] trunk/dports/databases
pixilla at macports.org
pixilla at macports.org
Thu Aug 23 11:00:37 PDT 2012
Revision: 96975
https://trac.macports.org/changeset/96975
Author: pixilla at macports.org
Date: 2012-08-23 11:00:33 -0700 (Thu, 23 Aug 2012)
Log Message:
-----------
databases/mysql55-connector-cpp:
- Update to version 1.1.1.
Modified Paths:
--------------
trunk/dports/databases/mysql55-connector-cpp/Portfile
Added Paths:
-----------
trunk/dports/databases/mysql55-connector-cpp/
trunk/dports/databases/mysql55-connector-cpp/files/
trunk/dports/databases/mysql55-connector-cpp/files/patch-CMakeLists.txt.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-cppconn-CMakeLists.txt.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-driver-CMakeLists.txt.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-examples.h.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-pthreads.cpp.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example.cpp.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs1.cpp.diff
trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs2.cpp.diff
Modified: trunk/dports/databases/mysql55-connector-cpp/Portfile
===================================================================
--- trunk/dports/databases/mysql-connector-cpp/Portfile 2012-08-16 16:27:13 UTC (rev 96664)
+++ trunk/dports/databases/mysql55-connector-cpp/Portfile 2012-08-23 18:00:33 UTC (rev 96975)
@@ -4,16 +4,14 @@
PortSystem 1.0
PortGroup cmake 1.0
-name mysql-connector-cpp
+name mysql55-connector-cpp
set name_package mysql-connector-c++
-version 1.1.0
+version 1.1.1
set branch [join [lrange [split ${version} .] 0 1] .]
categories databases
platforms darwin
-maintainers pixilla
+maintainers pixilla openmaintainer
license GPL-2
-description The MySQL Connector/C++
-long_description Standardized MySQL database driver for C++ development.
set mirror_dir Downloads/Connector-C++
homepage http://www.mysql.com/products/connector/
@@ -24,26 +22,91 @@
http://ftp.plusline.de/mysql/${mirror_dir}
distname ${name_package}-${version}
-checksums rmd160 f98bf0a4c987f49054da62e1e86197049b03250a \
- sha256 dfb8933dada706a1b3188b162fc5a9686b5ed46323bf09548ce291e8dd4545e2
+checksums rmd160 6415ae385effabb482b12cb9e39186d838d70d74 \
+ sha256 31c3e4f637153bd270812dffc6a50708dfc686a8afa7ea1c88a9dfda0d8af52e
depends_build-append \
port:boost
-depends_lib-append \
- port:mysql5
+patch.pre_args -p1
+patchfiles patch-CMakeLists.txt.diff \
+ patch-cppconn-CMakeLists.txt.diff \
+ patch-driver-CMakeLists.txt.diff \
+ patch-examples-examples.h.diff \
+ patch-examples-pthreads.cpp.diff \
+ patch-examples-standalone_example.cpp.diff \
+ patch-examples-standalone_example_docs1.cpp.diff \
+ patch-examples-standalone_example_docs2.cpp.diff
+
+post-patch {
+
+ reinplace "s, at NAME@,/${subport},g" \
+ ${worksrcpath}/cppconn/CMakeLists.txt \
+ ${worksrcpath}/driver/CMakeLists.txt
+}
+
configure.args-append \
- -DMYSQL_CONFIG_EXECUTABLE:FILEPATH=${prefix}/bin/mysql_config5 \
- -DMYSQLCPPCONN_BUILD_EXAMPLES:BOOL=1
+ -DCMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/${subport}
post-destroot {
- xinstall -d ${destroot}${prefix}/share/${name_package}
- eval move [glob -type f ${destroot}${prefix}/*] \
- ${destroot}${prefix}/share/${name_package}
+ xinstall -d ${destroot}${prefix}/share/${subport}
copy ${worksrcpath}/examples \
- ${destroot}${prefix}/share/${name_package}/
+ ${destroot}${prefix}/share/${subport}/
+
+ foreach lib [glob -directory ${destroot}${prefix}/lib/${subport} -type f *.dylib] {
+
+ system "install_name_tool -id ${prefix}/lib/${subport}/[strsed ${lib} /^.*\\///] ${lib}"
+ }
}
+set mp.ports {
+ mysql5
+ mysql51
+ mysql55
+ mariadb
+ percona
+}
+set mp.names {}
+foreach mp.port ${mp.ports} {
+
+ lappend mp.names "${mp.port}-connector-cpp"
+}
+foreach mp.name ${mp.names} {
+
+ set idx [lsearch ${mp.names} ${mp.name}]
+ set mp.port [lindex ${mp.ports} $idx]
+ set mp.conflicts [lreplace ${mp.names} $idx $idx]
+
+ if {[string compare ${mp.name} ${name}] == 0 && [string compare ${mp.name} ${subport}] == 0} {
+
+ description The MySQL Connector/C++ for ${mp.port}.
+ long_description ${description} \
+ Standardized MySQL database driver for C++ development.
+ depends_lib-append port:${mp.port}
+ configure.args-append \
+ -DMYSQLCPPCONN_DYNLOAD_MYSQL_LIB:FILEPATH=${prefix}/lib/${mp.port}/mysql/libmysqlclient.dylib \
+ -DMYSQL_CONFIG_EXECUTABLE:FILEPATH=${prefix}/lib/${mp.port}/bin/mysql_config
+ } else {
+
+ subport ${mp.name} {
+
+ description The MySQL Connector/C++ for ${mp.port}.
+ long_description ${description} \
+ Standardized MySQL database driver for C++ development.
+ depends_lib-append port:${mp.port}
+ configure.args-append \
+ -DMYSQLCPPCONN_DYNLOAD_MYSQL_LIB:FILEPATH=${prefix}/lib/${mp.port}/mysql/libmysqlclient.dylib \
+ -DMYSQL_CONFIG_EXECUTABLE:FILEPATH=${prefix}/lib/${mp.port}/bin/mysql_config
+ }
+ }
+}
+
+subport mysql-connector-cpp {
+
+ replaced_by mysql5-connector-cpp
+ PortGroup obsolete 1.0
+}
+
livecheck.type regex
livecheck.url [lindex ${master_sites} 0]
livecheck.regex "\"mysql-connector-c\\+\\+-(\\d\[\\d\\.\]*)\\${extract.suffix}\""
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-CMakeLists.txt.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-CMakeLists.txt.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-CMakeLists.txt.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,25 @@
+--- a/CMakeLists.txt 2012-08-16 12:15:30.000000000 -0700
++++ b/CMakeLists.txt 2012-08-23 08:36:04.000000000 -0700
+@@ -252,14 +252,6 @@
+ SET( LICENSE_FILENAME "${CPACK_RESOURCE_FILE_LICENSE}")")
+ ENDIF(WIN32)
+
+-INSTALL(FILES
+- ${CPACK_RESOURCE_FILE_README}
+- ${CPACK_RESOURCE_FILE_INSTALL}
+- ${CPACK_RESOURCE_FILE_LICENSE}
+- "${CMAKE_SOURCE_DIR}/Licenses_for_Third-Party_Components.txt"
+- "${CMAKE_SOURCE_DIR}/ANNOUNCEMENT"
+- DESTINATION "." OPTIONAL)
+-
+ SET(COMMON_IGNORE_FILES "/CMakeFiles/" "/Testing/" "/.bzr/" "_CPack_Packages/"
+ ".cmake$" "~" ".swp" ".log" ".gz" ".directory$" "CMakeCache.txt" "Makefile"
+ "install_manifest.txt")
+@@ -291,7 +283,6 @@
+
+ ADD_SUBDIRECTORY(cppconn)
+ ADD_SUBDIRECTORY(driver)
+-ADD_SUBDIRECTORY(examples)
+ ADD_SUBDIRECTORY(test)
+ ADD_SUBDIRECTORY(test/framework)
+ ADD_SUBDIRECTORY(test/CJUnitTestsPort)
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-cppconn-CMakeLists.txt.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-cppconn-CMakeLists.txt.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-cppconn-CMakeLists.txt.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,17 @@
+--- a/cppconn/CMakeLists.txt 2012-08-16 12:15:30.000000000 -0700
++++ b/cppconn/CMakeLists.txt 2012-08-23 07:14:51.000000000 -0700
+@@ -58,7 +58,6 @@
+
+ SET(MYSQLCPPCONN_INSTALL_HEADERS
+ build_config.h
+- config.h
+ connection.h
+ datatype.h
+ driver.h
+@@ -72,4 +71,5 @@
+ sqlstring.h
+ warning.h)
+
+-INSTALL(FILES ${MYSQLCPPCONN_INSTALL_HEADERS} DESTINATION include/cppconn)
++INSTALL(FILES ${MYSQLCPPCONN_INSTALL_HEADERS} DESTINATION include at NAME@/cppconn)
++INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include at NAME@/cppconn)
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-driver-CMakeLists.txt.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-driver-CMakeLists.txt.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-driver-CMakeLists.txt.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,44 @@
+--- a/driver/CMakeLists.txt 2012-08-16 12:15:30.000000000 -0700
++++ b/driver/CMakeLists.txt 2012-08-23 07:20:25.000000000 -0700
+@@ -275,18 +275,37 @@
+ )
+ ELSE(WIN32)
+ INSTALL(TARGETS mysqlcppconn mysqlcppconn-static
+- LIBRARY DESTINATION lib
+- ARCHIVE DESTINATION lib
++ LIBRARY DESTINATION lib at NAME@
++ ARCHIVE DESTINATION lib at NAME@
+ )
+ ENDIF(WIN32)
+
+
+ # Install some MySQL specific headers
+ SET(MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS
++ mysql_art_resultset.h
++ mysql_art_rset_metadata.h
+ mysql_connection.h
+- mysql_driver.h)
++ mysql_connection_data.h
++ mysql_connection_options.h
++ mysql_debug.h
++ mysql_driver.h
++ mysql_metadata.h
++ mysql_parameter_metadata.h
++ mysql_prepared_statement.h
++ mysql_ps_resultset.h
++ mysql_ps_resultset_metadata.h
++ mysql_public_iface.h
++ mysql_resultbind.h
++ mysql_resultset.h
++ mysql_resultset_metadata.h
++ mysql_statement.h
++ mysql_statement_options.h
++ mysql_uri.h
++ mysql_util.h
++ mysql_warning.h)
+
+-INSTALL(FILES ${MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS} DESTINATION include)
++INSTALL(FILES ${MYSQLCPPCONN_SPECIFIC_INSTALL_HEADERS} DESTINATION include at NAME@/driver)
+
+
+ MESSAGE(STATUS "Configuring driver")
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-examples.h.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-examples.h.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-examples.h.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,46 @@
+--- a/examples/examples.h 2012-08-16 12:15:30.000000000 -0700
++++ b/examples/examples.h 2012-08-23 10:05:54.000000000 -0700
+@@ -23,10 +23,25 @@
+ */
+
+
++// Connection properties
++#ifndef EXAMPLE_DB
++# define EXAMPLE_DB "test"
++#endif /* EXAMPLE_DB */
++#ifndef EXAMPLE_HOST
++# define EXAMPLE_HOST "tcp://127.0.0.1:3306"
++#endif /* EXAMPLE_HOST */
++#ifndef EXAMPLE_USER
++# define EXAMPLE_USER "root"
++#endif /* EXAMPLE_USER */
++#ifndef EXAMPLE_PASS
++# define EXAMPLE_PASS "root"
++#endif /* EXAMPLE_PASS */
++#ifndef DYNLOAD_MYSQL_LIB
++#define DYNLOAD_MYSQL_LIB "/opt/local/lib/mysql55/mysql/libmysqlclient_r.dylib"
++#endif /* DYNLOAD_MYSQL_LIB */
+
+ #ifndef _EXAMPLES_H
+ #define _EXAMPLES_H
+-
+ /*
+ __FUNCTION__/__func__ is not portable. We do not promise
+ that our example definition covers each and every compiler.
+@@ -57,15 +72,9 @@
+ works for you or you have to find your own.
+ */
+ #ifndef __LINE__
+- #define __LINE__ "(line number n/a)"
++#define __LINE__ "(line number n/a)"
+ #endif
+
+-// Connection properties
+-#define EXAMPLE_DB "test"
+-#define EXAMPLE_HOST "tcp://127.0.0.1:3306"
+-#define EXAMPLE_USER "root"
+-#define EXAMPLE_PASS "root"
+-
+ // Sample data
+ #define EXAMPLE_NUM_TEST_ROWS 4
+ struct _test_data {
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-pthreads.cpp.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-pthreads.cpp.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-pthreads.cpp.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,21 @@
+--- a/examples/pthreads.cpp 2012-08-16 12:15:30.000000000 -0700
++++ b/examples/pthreads.cpp 2012-08-23 10:05:54.000000000 -0700
+@@ -69,17 +69,13 @@
+ */
+ #include "mysql_connection.h"
+ #include "mysql_driver.h"
++#include "examples.h"
+
+ #include <cppconn/driver.h>
+ #include <cppconn/exception.h>
+ #include <cppconn/resultset.h>
+ #include <cppconn/statement.h>
+
+-#define EXAMPLE_HOST "localhost"
+-#define EXAMPLE_USER "root"
+-#define EXAMPLE_PASS ""
+-#define EXAMPLE_DB "test"
+-
+ struct st_worker_thread_param {
+ sql::Driver *driver;
+ sql::Connection *con;
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example.cpp.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example.cpp.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example.cpp.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,21 @@
+--- a/examples/standalone_example.cpp 2012-08-16 12:15:30.000000000 -0700
++++ b/examples/standalone_example.cpp 2012-08-23 10:05:54.000000000 -0700
+@@ -64,17 +64,13 @@
+ */
+ #include "mysql_connection.h"
+ #include "mysql_driver.h"
++#include "examples.h"
+
+ #include <cppconn/driver.h>
+ #include <cppconn/exception.h>
+ #include <cppconn/resultset.h>
+ #include <cppconn/statement.h>
+
+-#define EXAMPLE_HOST "localhost"
+-#define EXAMPLE_USER "root"
+-#define EXAMPLE_PASS ""
+-#define EXAMPLE_DB "test"
+-
+ using namespace std;
+
+ /**
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs1.cpp.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs1.cpp.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs1.cpp.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,115 @@
+--- a/examples/standalone_example_docs1.cpp 2012-08-16 12:15:30.000000000 -0700
++++ b/examples/standalone_example_docs1.cpp 2012-08-23 10:05:54.000000000 -0700
+@@ -19,7 +19,7 @@
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+@@ -35,6 +35,11 @@
+ */
+ #include "mysql_connection.h"
+
++/* Public interface of the MySQL Connector/C++ */
++#include <driver/mysql_public_iface.h>
++/* Connection parameter and sample data */
++#include "examples.h"
++
+ #include <cppconn/driver.h>
+ #include <cppconn/exception.h>
+ #include <cppconn/resultset.h>
+@@ -42,46 +47,52 @@
+
+ using namespace std;
+
+-int main(void)
++int main(int argc, const char **argv)
+ {
+-cout << endl;
+-cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl;
+-
+-try {
+- sql::Driver *driver;
+- sql::Connection *con;
+- sql::Statement *stmt;
+- sql::ResultSet *res;
+-
+- /* Create a connection */
+- driver = sql::mysql::get_driver_instance();
+- con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
+- /* Connect to the MySQL test database */
+- con->setSchema("test");
+-
+- stmt = con->createStatement();
+- res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
+- while (res->next()) {
+- cout << "\t... MySQL replies: ";
+- /* Access column data by alias or column name */
+- cout << res->getString("_message") << endl;
+- cout << "\t... MySQL says it again: ";
+- /* Access column fata by numeric offset, 1 is the first column */
+- cout << res->getString(1) << endl;
+- }
+- delete res;
+- delete stmt;
+- delete con;
+-
+-} catch (sql::SQLException &e) {
+- cout << "# ERR: SQLException in " << __FILE__;
+- cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
+- cout << "# ERR: " << e.what();
+- cout << " (MySQL error code: " << e.getErrorCode();
+- cout << ", SQLState: " << e.getSQLState() << " )" << endl;
+-}
++ static const string url(argc >= 2 ? argv[1] : EXAMPLE_HOST);
++ static const string user(argc >= 3 ? argv[2] : EXAMPLE_USER);
++ static const string pass(argc >= 4 ? argv[3] : EXAMPLE_PASS);
++ static const string database(argc >= 5 ? argv[4] : EXAMPLE_DB);
++
++ cout << endl;
++ cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl;
++
++ try {
++ sql::Driver *driver;
++ sql::Connection *con;
++ sql::Statement *stmt;
++ sql::ResultSet *res;
++
++ /* Create a connection */
++ driver = sql::mysql::get_driver_instance();
++
++ con = driver->connect(url, user, pass);
++ /* Connect to the MySQL test database */
++ con->setSchema(database);
++
++ stmt = con->createStatement();
++ res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
++ while (res->next()) {
++ cout << "\t... MySQL replies: ";
++ /* Access column data by alias or column name */
++ cout << res->getString("_message") << endl;
++ cout << "\t... MySQL says it again: ";
++ /* Access column fata by numeric offset, 1 is the first column */
++ cout << res->getString(1) << endl;
++ }
++ delete res;
++ delete stmt;
++ delete con;
++
++ } catch (sql::SQLException &e) {
++ cout << "# ERR: SQLException in " << __FILE__;
++ cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
++ cout << "# ERR: " << e.what();
++ cout << " (MySQL error code: " << e.getErrorCode();
++ cout << ", SQLState: " << e.getSQLState() << " )" << endl;
++ }
+
+-cout << endl;
++ cout << endl;
+
+-return EXIT_SUCCESS;
++ return EXIT_SUCCESS;
+ }
Added: trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs2.cpp.diff
===================================================================
--- trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs2.cpp.diff (rev 0)
+++ trunk/dports/databases/mysql55-connector-cpp/files/patch-examples-standalone_example_docs2.cpp.diff 2012-08-23 18:00:33 UTC (rev 96975)
@@ -0,0 +1,142 @@
+--- a/examples/standalone_example_docs2.cpp 2012-08-16 12:15:30.000000000 -0700
++++ b/examples/standalone_example_docs2.cpp 2012-08-23 10:05:54.000000000 -0700
+@@ -19,7 +19,7 @@
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+-51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
++51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+@@ -35,6 +35,11 @@
+ */
+ #include "mysql_connection.h"
+
++/* Public interface of the MySQL Connector/C++ */
++#include <driver/mysql_public_iface.h>
++/* Connection parameter and sample data */
++#include "examples.h"
++
+ #include <cppconn/driver.h>
+ #include <cppconn/exception.h>
+ #include <cppconn/resultset.h>
+@@ -43,59 +48,64 @@
+
+ using namespace std;
+
+-int main(void)
++int main(int argc, const char **argv)
+ {
+-cout << endl;
+-cout << "Let's have MySQL count from 10 to 1..." << endl;
+-
+-try {
+- sql::Driver *driver;
+- sql::Connection *con;
+- sql::Statement *stmt;
+- sql::ResultSet *res;
+- sql::PreparedStatement *pstmt;
+-
+- /* Create a connection */
+- driver = sql::mysql::get_driver_instance();
+- con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
+- /* Connect to the MySQL test database */
+- con->setSchema("test");
+-
+- stmt = con->createStatement();
+- stmt->execute("DROP TABLE IF EXISTS test");
+- stmt->execute("CREATE TABLE test(id INT)");
+- delete stmt;
+-
+- /* '?' is the supported placeholder syntax */
+- pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
+- for (int i = 1; i <= 10; i++) {
+- pstmt->setInt(1, i);
+- pstmt->executeUpdate();
+- }
+- delete pstmt;
+-
+- /* Select in ascending order */
+- pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
+- res = pstmt->executeQuery();
+-
+- /* Fetch in reverse = descending order! */
+- res->afterLast();
+- while (res->previous())
+- cout << "\t... MySQL counts: " << res->getInt("id") << endl;
+- delete res;
+-
+- delete pstmt;
+- delete con;
+-
+-} catch (sql::SQLException &e) {
+- cout << "# ERR: SQLException in " << __FILE__;
+- cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
+- cout << "# ERR: " << e.what();
+- cout << " (MySQL error code: " << e.getErrorCode();
+- cout << ", SQLState: " << e.getSQLState() << " )" << endl;
+-}
+-
+-cout << endl;
+-
+-return EXIT_SUCCESS;
++ static const string url(argc >= 2 ? argv[1] : EXAMPLE_HOST);
++ static const string user(argc >= 3 ? argv[2] : EXAMPLE_USER);
++ static const string pass(argc >= 4 ? argv[3] : EXAMPLE_PASS);
++ static const string database(argc >= 5 ? argv[4] : EXAMPLE_DB);
++
++ cout << endl;
++ cout << "Let's have MySQL count from 10 to 1..." << endl;
++
++ try {
++ sql::Driver *driver;
++ sql::Connection *con;
++ sql::Statement *stmt;
++ sql::ResultSet *res;
++ sql::PreparedStatement *pstmt;
++
++ /* Create a connection */
++ driver = sql::mysql::get_driver_instance();
++ con = driver->connect(url, user, pass);
++ /* Connect to the MySQL test database */
++ con->setSchema(database);
++
++ stmt = con->createStatement();
++ stmt->execute("DROP TABLE IF EXISTS test");
++ stmt->execute("CREATE TABLE test(id INT)");
++ delete stmt;
++
++ /* '?' is the supported placeholder syntax */
++ pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
++ for (int i = 1; i <= 10; i++) {
++ pstmt->setInt(1, i);
++ pstmt->executeUpdate();
++ }
++ delete pstmt;
++
++ /* Select in ascending order */
++ pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
++ res = pstmt->executeQuery();
++
++ /* Fetch in reverse = descending order! */
++ res->afterLast();
++ while (res->previous())
++ cout << "\t... MySQL counts: " << res->getInt("id") << endl;
++ delete res;
++
++ delete pstmt;
++ delete con;
++
++ } catch (sql::SQLException &e) {
++ cout << "# ERR: SQLException in " << __FILE__;
++ cout << "(" << EXAMPLE_FUNCTION << ") on line " << __LINE__ << endl;
++ cout << "# ERR: " << e.what();
++ cout << " (MySQL error code: " << e.getErrorCode();
++ cout << ", SQLState: " << e.getSQLState() << " )" << endl;
++ }
++
++ cout << endl;
++
++ return EXIT_SUCCESS;
+ }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120823/26e89e2f/attachment-0001.html>
More information about the macports-changes
mailing list