diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2062f9a..f186d24 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,7 +57,7 @@ SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
 # (but later on when installing)
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
-SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib")
+SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib;${INSTALL_ENGINE}/mysql/lib")
 
 # add the automatically determined parts of the RPATH
 # which point to directories outside the build tree to the install RPATH
@@ -69,6 +69,11 @@ IF("${isSystemDir}" STREQUAL "-1")
     SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/lib")
 ENDIF("${isSystemDir}" STREQUAL "-1")
 
+LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${SERVER_SOURCE_ROOT_DIR}/libmysql/" isSystemDir)
+IF("${isSystemDir}" STREQUAL "-1")
+    SET(CMAKE_INSTALL_RPATH "${INSTALL_ENGINE}/mysql/lib")
+ENDIF("${isSystemDir}" STREQUAL "-1")
+
 INCLUDE (configureEngine.cmake)
 
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/releasenum.in ${CMAKE_CURRENT_BINARY_DIR}/build/releasenum @ONLY IMMEDIATE)
@@ -125,7 +130,7 @@ SET (ENGINE_TOOLSDIR   "${INSTALL_ENGINE}/tools")
 SET (ENGINE_COMMON_LIBS     messageqcpp loggingcpp configcpp idbboot ${Boost_LIBRARIES} xml2 pthread rt)
 SET (ENGINE_OAM_LIBS        oamcpp alarmmanager)
 SET (ENGINE_BRM_LIBS        brm idbdatafile cacheutils rwlock ${ENGINE_OAM_LIBS} ${ENGINE_COMMON_LIBS})
-SET (ENGINE_EXEC_LIBS       joblist execplan windowfunction joiner rowgroup funcexp udfsdk dataconvert common compress mysqlcl_idb querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
+SET (ENGINE_EXEC_LIBS       joblist execplan windowfunction joiner rowgroup funcexp udfsdk dataconvert common compress querystats querytele thrift threadpool ${ENGINE_BRM_LIBS})
 SET (ENGINE_WRITE_LIBS      ddlpackageproc ddlpackage dmlpackageproc dmlpackage writeengine writeengineclient idbdatafile cacheutils ${ENGINE_EXEC_LIBS})
 
 SET (ENGINE_COMMON_LDFLAGS  "")
diff --git a/dbcon/joblist/CMakeLists.txt b/dbcon/joblist/CMakeLists.txt
index 989c3b7..bebe658 100644
--- a/dbcon/joblist/CMakeLists.txt
+++ b/dbcon/joblist/CMakeLists.txt
@@ -61,7 +61,7 @@ set(joblist_LIB_SRCS
 
 add_library(joblist SHARED ${joblist_LIB_SRCS})
 
-target_link_libraries(joblist ${NETSNMP_LIBRARIES})
+target_link_libraries(joblist ${NETSNMP_LIBRARIES} -L${SERVER_SOURCE_ROOT_DIR}/libmysql/ libmysqlclient_r.so)
 
 set_target_properties(joblist PROPERTIES VERSION 1.0.0 SOVERSION 1)
 
diff --git a/dbcon/joblist/crossenginestep.cpp b/dbcon/joblist/crossenginestep.cpp
index 98098fe..1a384ef 100644
--- a/dbcon/joblist/crossenginestep.cpp
+++ b/dbcon/joblist/crossenginestep.cpp
@@ -17,6 +17,7 @@
 
 //  $Id: crossenginestep.cpp 9709 2013-07-20 06:08:46Z xlou $
 
+#include "crossenginestep.h"
 #include <unistd.h>
 //#define NDEBUG
 #include <cassert>
@@ -55,89 +56,68 @@ using namespace querytele;
 
 #include "jobstep.h"
 #include "jlf_common.h"
-#include "crossenginestep.h"
-
-#include "libdrizzle-2.0/drizzle.h"
-#include "libdrizzle-2.0/drizzle_client.h"
 
 namespace joblist
 {
 
-DrizzleMySQL::DrizzleMySQL() : fDrzp(NULL), fDrzcp(NULL), fDrzrp(NULL)
+LibMySQL::LibMySQL() : fCon(NULL), fRes(NULL)
 {
 }
 
 
-DrizzleMySQL::~DrizzleMySQL()
+LibMySQL::~LibMySQL()
 {
-	if (fDrzrp)
-	{
-		drizzle_result_free(fDrzrp);
-	}
-	fDrzrp = NULL;
-
-	if (fDrzcp)
+	if (fRes)
 	{
-		drizzle_con_close(fDrzcp);
-		drizzle_con_free(fDrzcp);
+		mysql_free_result(fRes);
 	}
-	fDrzcp = NULL;
+	fRes = NULL;
 
-	if (fDrzp)
+	if (fCon)
 	{
-		drizzle_free(fDrzp);
+		mysql_close(fCon);
 	}
-	fDrzp = NULL;
+	fCon = NULL;
 }
 
 
-int DrizzleMySQL::init(const char* h, unsigned int p, const char* u, const char* w, const char* d)
+int LibMySQL::init(const char* h, unsigned int p, const char* u, const char* w, const char* d)
 {
-	int ret = -1;
+	int ret = 0;
 
-	fDrzp = drizzle_create();
-	if (fDrzp != NULL)
+	fCon = mysql_init(NULL);
+	if (fCon != NULL)
 	{
-		fDrzcp = drizzle_con_add_tcp(fDrzp, h, p, u, w, d, DRIZZLE_CON_MYSQL);
-		if (fDrzcp != NULL)
-		{
-			ret = drizzle_con_connect(fDrzcp);
-			if (ret != 0)
-				fErrStr = "fatal error in drizzle_con_connect()";
-		}
-		else
+		if (mysql_real_connect(fCon, h, u, w, d, p, NULL, 0) == NULL)
 		{
-			fErrStr = "fatal error in drizzle_con_add_tcp()";
+			fErrStr = "fatal error in mysql_real_connect()";
+            ret = mysql_errno(fCon);
 		}
 	}
 	else
 	{
-		fErrStr = "fatal error in drizzle_create()";
+		fErrStr = "fatal error in mysql_init()";
+        ret = -1;
 	}
 
 	return ret;
 }
 
 
-int DrizzleMySQL::run(const char* query)
+int LibMySQL::run(const char* query)
 {
 	int ret = 0;
-	drizzle_return_t drzret;
-	fDrzrp = drizzle_query_str(fDrzcp, fDrzrp, query, &drzret);
-	if (drzret == 0 && fDrzrp != NULL)
-	{
-		ret = drzret = drizzle_result_buffer(fDrzrp);
-		if (drzret != 0)
-			fErrStr = "fatal error reading result from crossengine client lib";
-	}
-	else
+    if (mysql_query(fCon, query) != 0)
 	{
-		fErrStr = "fatal error executing query in crossengine client lib";
-		if (drzret != 0)
-			ret = drzret;
-		else
-			ret = -1;
+		fErrStr = "fatal error reading result from crossengine client lib";
+        ret = -1;
 	}
+    fRes = mysql_use_result(fCon);
+    if (fRes == NULL)
+    {
+		fErrStr = "fatal error reading result from crossengine client lib";
+        ret = -1;
+    }
 
 	return ret;
 }
@@ -164,13 +144,13 @@ CrossEngineStep::CrossEngineStep(
 	fExtendedInfo = "CES: ";
 	getMysqldInfo(jobInfo);
 	fQtc.stepParms().stepType = StepTeleStats::T_CES;
-    drizzle = new DrizzleMySQL();
+    mysql = new LibMySQL();
 }
 
 
 CrossEngineStep::~CrossEngineStep()
 {
-    delete drizzle;
+    delete mysql;
 }
 
 
@@ -463,20 +443,20 @@ void CrossEngineStep::execute()
 		sts.total_units_of_work = 1;
 		postStepStartTele(sts);
 
-		ret = drizzle->init(fHost.c_str(), fPort, fUser.c_str(), fPasswd.c_str(), fSchema.c_str());
+		ret = mysql->init(fHost.c_str(), fPort, fUser.c_str(), fPasswd.c_str(), fSchema.c_str());
 		if (ret != 0)
-			handleMySqlError(drizzle->getError().c_str(), ret);
+			handleMySqlError(mysql->getError().c_str(), ret);
 
 		string query(makeQuery());
 		fLogger->logMessage(logging::LOG_TYPE_INFO, "QUERY to foreign engine: " + query);
 		if (traceOn())
 			cout << "QUERY: " << query << endl;
 
-		ret = drizzle->run(query.c_str());
+		ret = mysql->run(query.c_str());
 		if (ret != 0)
-			handleMySqlError(drizzle->getError().c_str(), ret);
+			handleMySqlError(mysql->getError().c_str(), ret);
 
-		int num_fields = drizzle->getFieldCount();
+		int num_fields = mysql->getFieldCount();
 
 		char** rowIn;                            // input
 		//shared_array<uint8_t> rgDataDelivered;      // output
@@ -497,7 +477,7 @@ void CrossEngineStep::execute()
 		bool doFE3 =  (fFeSelects.size() > 0);
 		if (!doFE1 && !doFE3)
 		{
-			while ((rowIn = drizzle->nextRow()) && !cancelled())
+			while ((rowIn = mysql->nextRow()) && !cancelled())
 			{
 				for(int i = 0; i < num_fields; i++)
 					setField(i, rowIn[i], fRowDelivered);
@@ -514,7 +494,7 @@ void CrossEngineStep::execute()
 			rgDataFe1.reset(new uint8_t[rowFe1.getSize()]);
 			rowFe1.setData(rgDataFe1.get());
 
-			while ((rowIn = drizzle->nextRow()) && !cancelled())
+			while ((rowIn = mysql->nextRow()) && !cancelled())
 			{
 				// Parse the columns used in FE1 first, the other column may not need be parsed.
 				for(int i = 0; i < num_fields; i++)
@@ -549,7 +529,7 @@ void CrossEngineStep::execute()
 			rgDataFe3.reset(new uint8_t[rowFe3.getSize()]);
 			rowFe3.setData(rgDataFe3.get());
 
-			while ((rowIn = drizzle->nextRow()) && !cancelled())
+			while ((rowIn = mysql->nextRow()) && !cancelled())
 			{
 				for(int i = 0; i < num_fields; i++)
 					setField(i, rowIn[i], rowFe3);
@@ -577,7 +557,7 @@ void CrossEngineStep::execute()
 			rgDataFe3.reset(new uint8_t[rowFe3.getSize()]);
 			rowFe3.setData(rgDataFe3.get());
 
-			while ((rowIn = drizzle->nextRow()) && !cancelled())
+			while ((rowIn = mysql->nextRow()) && !cancelled())
 			{
 				// Parse the columns used in FE1 first, the other column may not need be parsed.
 				for(int i = 0; i < num_fields; i++)
@@ -609,7 +589,7 @@ void CrossEngineStep::execute()
 
 		//INSERT_ADAPTER(fOutputDL, rgDataDelivered);
 		fOutputDL->insert(rgDataDelivered);
-		fRowsRetrieved = drizzle->getRowCount();
+		fRowsRetrieved = mysql->getRowCount();
 	}
 	catch (IDBExcept& iex)
 	{
diff --git a/dbcon/joblist/crossenginestep.h b/dbcon/joblist/crossenginestep.h
index a0f21cc..be83f6c 100644
--- a/dbcon/joblist/crossenginestep.h
+++ b/dbcon/joblist/crossenginestep.h
@@ -21,13 +21,15 @@
 #ifndef JOBLIST_CROSSENGINESTEP_H
 #define JOBLIST_CROSSENGINESTEP_H
 
+#include <my_config.h>
+#include <mysql.h>
+
 #include <boost/scoped_array.hpp>
 
 #include "jobstep.h"
 #include "primitivestep.h"
 
-#include "libdrizzle-2.0/drizzle.h"
-#include "libdrizzle-2.0/drizzle_client.h"
+using namespace std;
 
 // forward reference
 namespace  execplan
@@ -44,11 +46,11 @@ class FuncExp;
 namespace joblist
 {
 
-class DrizzleMySQL
+class LibMySQL
 {
 public:
-	DrizzleMySQL();
-	~DrizzleMySQL();
+	LibMySQL();
+	~LibMySQL();
 
 	// init:   host          port        username      passwd         db
 	int init(const char*, unsigned int, const char*, const char*, const char*);
@@ -56,16 +58,15 @@ public:
 	// run the query
 	int run(const char* q);
 
-	int getFieldCount()      { return drizzle_result_column_count(fDrzrp); }
-	int getRowCount()        { return drizzle_result_row_count(fDrzrp); }
-	char** nextRow()   { return drizzle_row_next(fDrzrp); }
-	const string& getError() { return fErrStr; }
+	int getFieldCount()      { return mysql_num_fields(fRes); }
+	int getRowCount()        { return mysql_num_rows(fRes); }
+	char** nextRow()   { return mysql_fetch_row(fRes); }
+	const std::string& getError() { return fErrStr; }
 
 private:
-	drizzle_st*        fDrzp;
-	drizzle_con_st*    fDrzcp;
-	drizzle_result_st* fDrzrp;
-	string             fErrStr;
+	MYSQL*        fCon;
+	MYSQL_RES*    fRes;
+    std::string             fErrStr;
 };
 
 /** @brief class CrossEngineStep
@@ -212,7 +213,7 @@ protected:
 	rowgroup::RowGroup fRowGroupFe3;
 
 	funcexp::FuncExp* fFeInstance;
-    DrizzleMySQL* drizzle;
+    LibMySQL* mysql;
 };
 
 
diff --git a/dbcon/joblist/jlf_graphics.cpp b/dbcon/joblist/jlf_graphics.cpp
index c81898e..5983706 100644
--- a/dbcon/joblist/jlf_graphics.cpp
+++ b/dbcon/joblist/jlf_graphics.cpp
@@ -17,12 +17,13 @@
 
 // $Id: jlf_graphics.cpp 9550 2013-05-17 23:58:07Z xlou $
 
+// Cross engine at the top due to MySQL includes
+#include "crossenginestep.h"
 #include <iostream>
 using namespace std;
 
 #include "joblist.h"
 #include "primitivestep.h"
-#include "crossenginestep.h"
 #include "subquerystep.h"
 #include "windowfunctionstep.h"
 #include "tupleaggregatestep.h"
diff --git a/dbcon/joblist/jlf_tuplejoblist.cpp b/dbcon/joblist/jlf_tuplejoblist.cpp
index ed9bacc..efac6ea 100644
--- a/dbcon/joblist/jlf_tuplejoblist.cpp
+++ b/dbcon/joblist/jlf_tuplejoblist.cpp
@@ -17,7 +17,8 @@
 
 //  $Id: jlf_tuplejoblist.cpp 9728 2013-07-26 22:08:20Z xlou $
 
-
+// Cross engine needs to be at the top due to MySQL includes
+#include "crossenginestep.h"
 #include <iostream>
 #include <stack>
 #include <iterator>
@@ -55,7 +56,6 @@ using namespace dataconvert;
 #include "limitedorderby.h"
 #include "jobstep.h"
 #include "primitivestep.h"
-#include "crossenginestep.h"
 #include "expressionstep.h"
 #include "subquerystep.h"
 #include "tupleaggregatestep.h"
diff --git a/dbcon/joblist/joblist.cpp b/dbcon/joblist/joblist.cpp
index e4da0e5..f70b815 100644
--- a/dbcon/joblist/joblist.cpp
+++ b/dbcon/joblist/joblist.cpp
@@ -18,7 +18,8 @@
 
 //  $Id: joblist.cpp 9655 2013-06-25 23:08:13Z xlou $
 
-
+// Cross engine needs to be at the top due to MySQL includes
+#include "crossenginestep.h"
 #include "errorcodes.h"
 #include <iterator>
 #include <stdexcept>
@@ -34,7 +35,6 @@ using namespace execplan;
 #include "errorids.h"
 #include "jobstep.h"
 #include "primitivestep.h"
-#include "crossenginestep.h"
 #include "subquerystep.h"
 #include "tupleaggregatestep.h"
 #include "tupleannexstep.h"
diff --git a/dbcon/joblist/tupleaggregatestep.cpp b/dbcon/joblist/tupleaggregatestep.cpp
index 595cb17..eb6f438 100644
--- a/dbcon/joblist/tupleaggregatestep.cpp
+++ b/dbcon/joblist/tupleaggregatestep.cpp
@@ -19,6 +19,9 @@
 
 
 //#define NDEBUG
+// Cross engine needs to be at top due to MySQL includes
+#include "crossenginestep.h"
+
 #include <cassert>
 #include <sstream>
 #include <iomanip>
@@ -61,7 +64,6 @@ using namespace querytele;
 #include "primitivestep.h"
 #include "subquerystep.h"
 #include "tuplehashjoin.h"
-#include "crossenginestep.h"
 #include "tupleaggregatestep.h"
 
 //#include "stopwatch.cpp"
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 744f6b4..d12f378 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -16,7 +16,6 @@ add_subdirectory(udfsdk)
 add_subdirectory(compress)
 add_subdirectory(batchloader)
 add_subdirectory(ddlcleanup)
-add_subdirectory(mysqlcl_idb)
 add_subdirectory(querystats)
 add_subdirectory(windowfunction)
 add_subdirectory(idbdatafile)
diff --git a/utils/querystats/CMakeLists.txt b/utils/querystats/CMakeLists.txt
index 940749a..0012118 100644
--- a/utils/querystats/CMakeLists.txt
+++ b/utils/querystats/CMakeLists.txt
@@ -8,6 +8,8 @@ set(querystats_LIB_SRCS querystats.cpp)
 
 add_library(querystats SHARED ${querystats_LIB_SRCS})
 
+target_link_libraries(querystats -L${SERVER_SOURCE_ROOT_DIR}/libmysql/ libmysqlclient_r.so)
+
 set_target_properties(querystats PROPERTIES VERSION 1.0.0 SOVERSION 1)
 
 install(TARGETS querystats DESTINATION ${ENGINE_LIBDIR} COMPONENT libs)
diff --git a/utils/querystats/querystats.cpp b/utils/querystats/querystats.cpp
index ef593b3..88dab5d 100644
--- a/utils/querystats/querystats.cpp
+++ b/utils/querystats/querystats.cpp
@@ -21,6 +21,8 @@
 *
 ***********************************************************************/
 
+#include <my_config.h>
+#include <mysql.h>
 #include <string>
 using namespace std;
 
@@ -37,28 +39,24 @@ using namespace logging;
 
 #include "querystats.h"
 
-#include "libdrizzle-2.0/drizzle.h"
-#include "libdrizzle-2.0/drizzle_client.h"
-
 namespace querystats
 {
 	
 const string SCHEMA = "infinidb_querystats";
 
-struct IDB_Drizzle
+struct IDB_MySQL
 {
-	IDB_Drizzle(): drzp(NULL), drzcp(NULL), drzrp(NULL) {}
-	~IDB_Drizzle() 
+	IDB_MySQL(): fCon(NULL), fRes(NULL) {}
+	~IDB_MySQL()
 	{
-		// The following API all checks NULL in the implementation.
-		drizzle_result_free(drzrp);
-		drizzle_con_close(drzcp);
-		drizzle_con_free(drzcp);
-		drizzle_free(drzp);
+        if (fRes)
+            mysql_free_result(fRes);
+
+        if (fCon)
+            mysql_close(fCon);
 	}
-	drizzle_st* drzp;
-	drizzle_con_st* drzcp;
-	drizzle_result_st* drzrp;
+	MYSQL* fCon;
+	MYSQL_RES* fRes;
 };
 
 QueryStats::QueryStats()
@@ -206,25 +204,19 @@ void QueryStats::insert()
 			ERR_CROSS_ENGINE_CONFIG);
 
 	// insert stats to querystats table
-	IDB_Drizzle drizzle;
+	IDB_MySQL mysql;
 
-	drizzle.drzp = drizzle_create();
-	if (drizzle.drzp == 0)
+	mysql.fCon = mysql_init(NULL);
+	if (mysql.fCon == NULL)
 		handleMySqlError("fatal error initializing querystats lib", -1);
 
-	drizzle.drzcp = drizzle_con_add_tcp(drizzle.drzp, host.c_str(), port, user.c_str(), pwd.c_str(),
-		SCHEMA.c_str(), DRIZZLE_CON_MYSQL);
-	if (drizzle.drzcp == 0)
-		handleMySqlError("fatal error setting up parms in querystats lib", -1);
-
-	drizzle_return_t drzret;
-	drzret = drizzle_con_connect(drizzle.drzcp);
-	if (drzret != 0)
-		handleMySqlError("fatal error connecting to InfiniDB in querystats lib", drzret);
+    if (mysql_real_connect(mysql.fCon, host.c_str(), user.c_str(), pwd.c_str(),
+		SCHEMA.c_str(), port, NULL, 0) == NULL)
+		handleMySqlError("fatal error setting up parms in querystats lib", mysql_errno(mysql.fCon));
 
 	// escape quote characters
 	boost::scoped_array<char> query(new char[fQuery.length()*2+1]);
-	drizzle_escape_string(query.get(), fQuery.length()*2, fQuery.c_str(), fQuery.length());
+    mysql_real_escape_string(mysql.fCon, query.get(), fQuery.c_str(), fQuery.length());
 
 	ostringstream insert;
 	insert << "insert delayed into querystats values (0, ";
@@ -248,14 +240,10 @@ void QueryStats::insert()
 	insert << fBlocksChanged << ", ";
 	insert << fNumFiles << ", ";
 	insert << fFileBytes << ")"; // the last 2 fields are not populated yet
-	
-	drizzle.drzrp = drizzle_query_str(drizzle.drzcp, drizzle.drzrp, insert.str().c_str(), &drzret);
-	if (drzret != 0 || drizzle.drzrp == 0)
-		handleMySqlError("fatal error executing query in querystats lib", drzret);
 
-	drzret = drizzle_result_buffer(drizzle.drzrp);
-	if (drzret != 0)
-		handleMySqlError("fatal error reading results from InfiniDB in querystats lib", drzret);
+	int ret = mysql_query(mysql.fCon, insert.str().c_str());
+	if (ret != 0)
+		handleMySqlError("fatal error executing query in querystats lib", ret);
 }
 
 void QueryStats::handleMySqlError(const char* errStr, unsigned int errCode)
@@ -294,19 +282,14 @@ uint32_t QueryStats::userPriority(string _host, const string _user)
 			ERR_CROSS_ENGINE_CONFIG);
 
 	// get user priority
-	IDB_Drizzle drizzle;
-	drizzle.drzp = drizzle_create();
-	if (drizzle.drzp == 0)
+	IDB_MySQL mysql;
+	mysql.fCon = mysql_init(NULL);
+	if (mysql.fCon == NULL)
 		handleMySqlError("fatal error initializing querystats lib", -1);
 
-	drizzle.drzcp = drizzle_con_add_tcp(drizzle.drzp, host.c_str(), port, user.c_str(), pwd.c_str(),
-		SCHEMA.c_str(), DRIZZLE_CON_MYSQL);
-	if (drizzle.drzcp == 0)
-		handleMySqlError("fatal error setting up parms in querystats lib", -1);
-	drizzle_return_t drzret;
-	drzret = drizzle_con_connect(drizzle.drzcp);
-	if (drzret != 0)
-		handleMySqlError("fatal error connecting to InfiniDB in querystats lib", drzret);
+    if (mysql_real_connect(mysql.fCon, host.c_str(), user.c_str(), pwd.c_str(),
+		SCHEMA.c_str(), port, NULL, 0) == NULL)
+		handleMySqlError("fatal error connecting to InfiniDB in querystats lib", mysql_errno(mysql.fCon));
 	
 	// get the part of host string befor ':' if there is.
 	size_t pos = _host.find(':', 0);
@@ -324,16 +307,18 @@ uint32_t QueryStats::userPriority(string _host, const string _user)
 	      << _user 
 	      << "') and upper(a.priority) = upper(b.priority)";
 
-	drizzle.drzrp = drizzle_query_str(drizzle.drzcp, drizzle.drzrp, query.str().c_str(), &drzret);
-	if (drzret != 0 || drizzle.drzrp == 0)
-		handleMySqlError("fatal error executing query in querystats lib", drzret);
-	drzret = drizzle_result_buffer(drizzle.drzrp);
-	if (drzret != 0)
-		handleMySqlError("fatal error reading results from InfiniDB in querystats lib", drzret);
+    int ret =mysql_query(mysql.fCon, query.str().c_str());
+    if (ret != 0)
+		handleMySqlError("fatal error executing query in querystats lib", ret);
+    // Using mysql_store_result here as for mysql_use_result we would need to get every row
+    // Maybe limit 1 on the query in the future?
+    mysql.fRes = mysql_store_result(mysql.fCon);
+	if (mysql.fRes == NULL)
+		handleMySqlError("fatal error reading results from InfiniDB in querystats lib", mysql_errno(mysql.fCon));
 
 	// only fetch one row. if duplicate user name in the table, the first one will be got.
-	drizzle_row_t row;
-	row = drizzle_row_next(drizzle.drzrp);
+	MYSQL_ROW row;
+	row = mysql_fetch_row(mysql.fRes);
 	if (row)
 	{
 		fPriority = row[0];
