MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:jstephens Date:August 5 2006 1:18pm
Subject:svn commit - mysqldoc@docsrva: r2957 - trunk/ndbapi
View as plain text  
Author: jstephens
Date: 2006-08-05 15:18:15 +0200 (Sat, 05 Aug 2006)
New Revision: 2957

Log:
Fixed invalid m4 listing; updated simple connection example.

Fixes Bug #21439. (Thanks, Stewart!)

Modified:
   trunk/ndbapi/getting-started.xml


Modified: trunk/ndbapi/getting-started.xml
===================================================================
--- trunk/ndbapi/getting-started.xml	2006-08-05 13:03:52 UTC (rev 2956)
+++ trunk/ndbapi/getting-started.xml	2006-08-05 13:18:15 UTC (rev 2957)
Changed blocks: 2, Lines Added: 23, Lines Deleted: 33; 2755 bytes

@@ -347,13 +347,14 @@
 
     # add NDB API specific C flags
     IBASE=`$MYSQL_CONFIG --include`
-    ADDFLAGS="$ADDFLAGS $IBASE/ndb"
-    ADDFLAGS="$ADDFLAGS $IBASE/ndb/ndbapi"
-    ADDFLAGS="$ADDFLAGS $IBASE/ndb/mgmapi"
+    ADDFLAGS="$ADDFLAGS $IBASE/storage/ndb"
+    ADDFLAGS="$ADDFLAGS $IBASE/storage/ndb/ndbapi"
+    ADDFLAGS="$ADDFLAGS $IBASE/storage/ndb/mgmapi"
 
     CFLAGS="$CFLAGS $ADDFLAGS"    
     CXXFLAGS="$CXXFLAGS $ADDFLAGS"    
 
+    LDFLAGS="$LDFLAGS "`$MYSQL_CONFIG --libs_r`" -lndbclient -lmystrings -lmysys"
     LDFLAGS="$LDFLAGS "`$MYSQL_CONFIG --libs_r`" -lndbclient -lmystrings"
     
     AC_MSG_RESULT($MYSQL_CONFIG)

@@ -494,61 +495,50 @@
 <programlisting>
 #include &lt;stdio.h&gt;
 #include &lt;stdlib.h&gt;
-
 #include &lt;NdbApi.hpp&gt;
+#include &lt;mysql.h&gt;
+#include &lt;mgmapi.h&gt;
 
-#define CONNECTSTR "localhost"
+Ndb_cluster_connection* connect_to_cluster();
+void disconnect_from_cluster(Ndb_cluster_connection *c);
 
-Ndb_cluster_connection* example_init()
+Ndb_cluster_connection* connect_to_cluster()
 {
-  Ndb_cluster_connection* conn;
+  Ndb_cluster_connection* c;
 
-  // initialise MySQL and Ndb client libraries
-  if( ndb_init() )
-  {
+  if(ndb_init())
     exit(EXIT_FAILURE);
-  }
 
-  // prepare connection to cluster
-  conn = new Ndb_cluster_connection(CONNECTSTR);
+  c= new Ndb_cluster_connection();
 
-  // initiate connection
-  if( conn-&gt;connect(4, 5, 1) )
+  if(c-&gt;connect(4, 5, 1))
   {
-    fprintf(stderr, "Unable to connect to cluster within 30 seconds.");
+    fprintf(stderr, "Unable to connect to cluster within 30 seconds.\n\n");
     exit(EXIT_FAILURE);
   }
-  
-  // wait for data (ndbd) nodes
-  if(conn-&gt;wait_until_ready(30, 0) &lt; 0)
+
+  if(c-&gt;wait_until_ready(30, 0) &lt; 0)
   {
-    fprintf(stderr, "Cluster was not ready within 30 seconds.\n");
+    fprintf(stderr, "Cluster was not ready within 30 seconds.\n\n");
     exit(EXIT_FAILURE);
   }
-
-  return conn; 
 }
 
-void example_end(Ndb_cluster_connection* conn)
+void disconnect_from_cluster(Ndb_cluster_connection *c)
 {
-  // terminate connection
-  delete conn;
+  delete c;
 
-  // shut down MySQL and Ndb client libraries
   ndb_end(2);
 }
 
-
-int main(int argc, char** argv)
+int main(int argc, char* argv[])
 {
-  Ndb_cluster_connection* conn;
+  Ndb_cluster_connection *ndb_connection= connect_to_cluster();
 
-  conn = example_connect();
+  printf("Connection Established.\n\n");
 
-  printf("Connection established.");
+  disconnect_from_cluster(ndb_connection);
 
-  example_end(conn);
-
   return EXIT_SUCCESS;
 }
 </programlisting>


Thread
svn commit - mysqldoc@docsrva: r2957 - trunk/ndbapijstephens5 Aug