Commit 52722f1b authored by unknown's avatar unknown
Browse files

updated ndbapi examples

parent 865d0329
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
-include .defs.mk

#ifneq ($(C++),)
#OPTS = CC=$(CC) CXX=$(C++)
#endif

# XXX ndbapi_example4 commented out until fixed
# XXX ndbapi_example4, select_all commented out until fixed
BIN_DIRS := ndbapi_example1 ndbapi_example2 ndbapi_example3  $(ndbapi_example4) \
	    ndbapi_example5 select_all
	    ndbapi_example5 $(select_all) ndbapi_scan_example

bins: $(patsubst %, _bins_%, $(BIN_DIRS))

@@ -24,4 +18,3 @@ clean_dep: clean
cleanall: clean
tidy: clean
distclean: clean
+4 −16
Original line number Diff line number Diff line
-include .defs.mk
#NDB_OS = OS_YOU_ARE_RUNNING_ON
#You need to set the NDB_OS variable here
TARGET = ndbapi_example1
SRCS = ndbapi_example1.cpp
OBJS = ndbapi_example1.o
@@ -9,22 +6,13 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG = 
LFLAGS = -Wall
INCLUDE_DIR = ../../include
LIB_DIR = ../../lib
ifeq ($(NDB_OS), SOLARIS)
# Here is the definition of system libraries necessary for Solaris 7
LIB_DIR = -L../../src/.libs \
          -L../../../libmysql/.libs \
          -L../../../mysys
SYS_LIB = 
endif
ifeq ($(NDB_OS), LINUX)
# Here is the definition of system libraries necessary for Linux 2.4
SYS_LIB = 
endif
ifeq ($(NDB_OS), MACOSX)
# Here is the definition of system libraries necessary for Mac OS X
SYS_LIB = 
endif

$(TARGET): $(OBJS)
	$(CXX) $(LFLAGS) -L$(LIB_DIR) $(OBJS) -lNDB_API $(SYS_LIB) -o $(TARGET)
	$(CXX) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient -lmysys $(SYS_LIB) -o $(TARGET)

$(TARGET).o: $(SRCS)
	$(CXX) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
+18 −7
Original line number Diff line number Diff line
@@ -45,7 +45,18 @@
int main()
{
  ndb_init();
  Ndb* myNdb = new Ndb( "TEST_DB_1" );  // Object representing the database

  Ndb_cluster_connection *cluster_connection=
    new Ndb_cluster_connection(); // Object representing the cluster

  if (cluster_connection->wait_until_ready(30,30))
  {
    std::cout << "Cluster was not ready within 30 secs." << std::endl;
    exit(-1);
  }

  Ndb* myNdb = new Ndb( cluster_connection,
			"TEST_DB_1" );  // Object representing the database
  NdbDictionary::Table myTable;
  NdbDictionary::Column myColumn;

@@ -56,16 +67,11 @@ int main()
  /********************************************
   * Initialize NDB and wait until it's ready *
   ********************************************/
  if (myNdb->init() == -1) { 
  if (myNdb->init()) { 
    APIERROR(myNdb->getNdbError());
    exit(-1);
  }

  if (myNdb->waitUntilReady(30) != 0) {
    std::cout << "NDB was not ready within 30 secs." << std::endl;
    exit(-1);
  }
  
  NdbDictionary::Dictionary* myDict = myNdb->getDictionary();
  
  /*********************************************************
@@ -190,5 +196,10 @@ int main()
    }
    myNdb->closeTransaction(myConnection);
  }

  delete myNdb;
  delete cluster_connection;

  ndb_end(0);
  return 0;
}
+4 −16
Original line number Diff line number Diff line
-include .defs.mk
#NDB_OS = OS_YOU_ARE_RUNNING_ON
#You need to set the NDB_OS variable here
TARGET = ndbapi_example2
SRCS = ndbapi_example2.cpp
OBJS = ndbapi_example2.o
@@ -9,22 +6,13 @@ CFLAGS = -c -Wall -fno-rtti -fno-exceptions
DEBUG = 
LFLAGS = -Wall
INCLUDE_DIR = ../../include
LIB_DIR = ../../lib
ifeq ($(NDB_OS), SOLARIS)
# Here is the definition of system libraries necessary for Solaris 7
LIB_DIR = -L../../src/.libs \
          -L../../../libmysql/.libs \
          -L../../../mysys
SYS_LIB = 
endif
ifeq ($(NDB_OS), LINUX)
# Here is the definition of system libraries necessary for Linux 2.4
SYS_LIB = 
endif
ifeq ($(NDB_OS), MACOSX)
# Here is the definition of system libraries necessary for Mac OS X
SYS_LIB = 
endif

$(TARGET): $(OBJS)
	$(CXX) $(LFLAGS) -L$(LIB_DIR) $(OBJS) -lNDB_API $(SYS_LIB) -o $(TARGET)
	$(CXX) $(LFLAGS) $(LIB_DIR) $(OBJS) -lndbclient -lmysqlclient -lmysys $(SYS_LIB) -o $(TARGET)

$(TARGET).o: $(SRCS)
	$(CXX) $(CFLAGS) -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/ndbapi $(SRCS)
+16 −1
Original line number Diff line number Diff line
@@ -40,7 +40,18 @@ static void callback(int result, NdbConnection* NdbObject, void* aObject);
int main()
{
  ndb_init();
  Ndb* myNdb = new Ndb( "TEST_DB_2" );  // Object representing the database

  Ndb_cluster_connection *cluster_connection=
    new Ndb_cluster_connection(); // Object representing the cluster

  if (cluster_connection->wait_until_ready(30,30))
  {
    std::cout << "Cluster was not ready within 30 secs." << std::endl;
    exit(-1);
  }

  Ndb* myNdb = new Ndb( cluster_connection,
			"TEST_DB_2" );  // Object representing the database

  NdbConnection*  myNdbConnection[2];   // For transactions
  NdbOperation*   myNdbOperation;       // For operations
@@ -88,6 +99,10 @@ int main()
    myNdb->closeTransaction(myNdbConnection[i]);

  delete myNdb;
  delete cluster_connection;

  ndb_end(0);
  return 0;
}

/*
Loading