diff --git a/.gitignore b/.gitignore index 5ea512d..09a3bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /3rdPartner/frp_0.56.0_linux_arm.tar.gz /3rdPartner/go1.22.1.linux-armv6l.tar.gz /appRelease/test.release +/sdk/include/SQLiteCpp diff --git a/applications/WebConfigure/cgiCommon/cgiCommon.sln b/applications/WebConfigure/cgiCommon/cgiCommon.sln index e8e7f9d..1dd6e37 100644 --- a/applications/WebConfigure/cgiCommon/cgiCommon.sln +++ b/applications/WebConfigure/cgiCommon/cgiCommon.sln @@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.34301.259 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgiCommon", "cgiCommon.vcxproj", "{EC275930-0379-4487-8C30-EAFE2C124618}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopdb", "..\..\library\libopdb\libopdb.vcxproj", "{E8431BFC-D508-428C-AC1D-A64539C5FC18}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsondemo2", "..\..\examples\jsondemo2\jsondemo2.vcxproj", "{A7EA55C7-9DC1-4903-9470-66F3BF247D28}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -41,6 +45,42 @@ Global {EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.ActiveCfg = Release|x86 {EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.Build.0 = Release|x86 {EC275930-0379-4487-8C30-EAFE2C124618}.Release|x86.Deploy.0 = Release|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.ActiveCfg = Debug|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.Build.0 = Debug|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM.Deploy.0 = Debug|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.Build.0 = Debug|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.ActiveCfg = Debug|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.Build.0 = Debug|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x64.Deploy.0 = Debug|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.ActiveCfg = Debug|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.Build.0 = Debug|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Debug|x86.Deploy.0 = Debug|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.ActiveCfg = Release|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.Build.0 = Release|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM.Deploy.0 = Release|ARM + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.ActiveCfg = Release|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.Build.0 = Release|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|ARM64.Deploy.0 = Release|ARM64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.ActiveCfg = Release|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.Build.0 = Release|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x64.Deploy.0 = Release|x64 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.ActiveCfg = Release|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.Build.0 = Release|x86 + {E8431BFC-D508-428C-AC1D-A64539C5FC18}.Release|x86.Deploy.0 = Release|x86 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|ARM.ActiveCfg = Debug|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|ARM64.ActiveCfg = Debug|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x64.ActiveCfg = Debug|x64 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x64.Build.0 = Debug|x64 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x86.ActiveCfg = Debug|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Debug|x86.Build.0 = Debug|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|ARM.ActiveCfg = Release|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|ARM64.ActiveCfg = Release|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x64.ActiveCfg = Release|x64 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x64.Build.0 = Release|x64 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x86.ActiveCfg = Release|Win32 + {A7EA55C7-9DC1-4903-9470-66F3BF247D28}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj b/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj index 2456ef5..57fc77f 100644 --- a/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj +++ b/applications/WebConfigure/cgiCommon/cgiCommon.vcxproj @@ -82,7 +82,7 @@ D:\My Documents\汇珏网络\15. EMS\projects\sdk\include - D:\My Documents\汇珏网络\15. EMS\projects\sdk\include;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\cgicc;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\hv;D:\My Documents\汇珏网络\15. EMS\projects\sdk\include\nlohmann;$(IncludePath) + D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\cgicc;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\hv;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\nlohmann;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\sodium;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\spdlog;D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include\zmqpp;$(IncludePath) diff --git a/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp b/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp index 30c246d..abda9cb 100644 --- a/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp +++ b/applications/WebConfigure/cgiCommon/handleLoginRequest.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "handleHeader.h" using namespace cgicc; @@ -43,7 +44,7 @@ void handleLoginRequest(cgicc::Cgicc& cgi) std::cout << "
\n"; // ¼߼... - // ֤ɹ + std::cout << "
\n"; std::cout << username.c_str() << std::endl; diff --git a/applications/library/libopdb/libopdb.vcxproj b/applications/library/libopdb/libopdb.vcxproj index 13ff1e7..0ce8ac1 100644 --- a/applications/library/libopdb/libopdb.vcxproj +++ b/applications/library/libopdb/libopdb.vcxproj @@ -77,6 +77,9 @@ D:\My Documents\汇珏网络\15. EMS\projects\sdk\include;$(IncludePath) + + D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include;$(IncludePath) + @@ -89,7 +92,11 @@ - + + + D:\My Documents\汇珏网络\15. EMS\projects\emsApplication\sdk\include;%(AdditionalIncludeDirectories) + + \ No newline at end of file diff --git a/applications/library/libopdb/opdatabase.cpp b/applications/library/libopdb/opdatabase.cpp index 02e203a..8a55819 100644 --- a/applications/library/libopdb/opdatabase.cpp +++ b/applications/library/libopdb/opdatabase.cpp @@ -2,6 +2,8 @@ #include #include #include +#include "openjson.h" + OpDatabase::OpDatabase() :m_pSqliteDb(nullptr) @@ -58,12 +60,20 @@ void OpDatabase::InsertMessage(const std::string& ts, const std::string& msg_typ } } -bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd) +bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd, std::string& resultJson) { const char* queryDataSQL = "SELECT * FROM tbl_user WHERE uid=?;"; sqlite3_stmt * statement; + bool ret = false; - if (sqlite3_prepare_v2(m_pSqliteDb, queryDataSQL, -1, &statement, nullptr) == SQLITE_OK) + int rc = sqlite3_prepare_v2(m_pSqliteDb, queryDataSQL, -1, &statement, nullptr); + if (rc != SQLITE_OK) + { + hloge("SQL error: %s ", sqlite3_errmsg(m_pSqliteDb)); + return ret; + } + + if ( rc == SQLITE_OK) { // 󶨲 sqlite3_bind_text(statement, 1, uname.c_str(), -1, SQLITE_STATIC); @@ -71,27 +81,34 @@ bool OpDatabase::QueryUser(const std::string& uname, const std::string& passwd) // ִ if (sqlite3_step(statement) != SQLITE_DONE) { - hlogw("Error query user %s", uname.c_str()); + hloge("Error query user %s", uname.c_str()); } else { + OpenJson json; + auto& nodeRoot = json["users"]; + size_t i = 0; // while (sqlite3_step(statement) == SQLITE_ROW) { - hlogi("Userid: %s", sqlite3_column_text(statement, 0)); - hlogi("UserName: %s", sqlite3_column_text(statement, 1)); - hlogi("UserSalt: %s", sqlite3_column_text(statement, 2)); - hlogi("UserPasswd: %s", sqlite3_column_text(statement, 3)); + auto& node = nodeRoot[i]; + node["id"] = sqlite3_column_text(statement, 0); + node["user"] = sqlite3_column_text(statement, 1); + node["salt"] = sqlite3_column_text(statement, 2); + node["passwd"] = sqlite3_column_text(statement, 3); } + + resultJson = json.encode(); + ret = true; } // ͷԴ sqlite3_finalize(statement); - return true; + return ret; } - return false; + return ret; } diff --git a/applications/library/libopdb/opdatabase.h b/applications/library/libopdb/opdatabase.h index faed5a7..edc5ce5 100644 --- a/applications/library/libopdb/opdatabase.h +++ b/applications/library/libopdb/opdatabase.h @@ -12,7 +12,7 @@ public: void CloseDatabase(); bool OpenDatabase(const std::string& db_file_path); void InsertMessage(const std::string& ts, const std::string& msg_type, const std::string& fsu, const std::string& content,int topic,int dev_id); - bool QueryUser(const std::string& uname, const std::string& passwd); + bool QueryUser(const std::string& uname, const std::string& passwd, std::string& resultJson); protected: sqlite3* m_pSqliteDb; private: diff --git a/sdk/include/cppconn/build_config.h b/sdk/include/cppconn/build_config.h new file mode 100644 index 0000000..f912807 --- /dev/null +++ b/sdk/include/cppconn/build_config.h @@ -0,0 +1,49 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_BUILD_CONFIG_H_ +#define _SQL_BUILD_CONFIG_H_ + +#ifndef CPPCONN_PUBLIC_FUNC + +#if defined(_WIN32) + // mysqlcppconn_EXPORTS is added by cmake and defined for dynamic lib build only + #ifdef mysqlcppconn_EXPORTS + #define CPPCONN_PUBLIC_FUNC __declspec(dllexport) + #else + // this is for static build + #ifdef CPPCONN_LIB_BUILD + #define CPPCONN_PUBLIC_FUNC + #else + // this is for clients using dynamic lib + #define CPPCONN_PUBLIC_FUNC __declspec(dllimport) + #endif + #endif +#else + #define CPPCONN_PUBLIC_FUNC +#endif + +#endif //#ifndef CPPCONN_PUBLIC_FUNC + +#endif //#ifndef _SQL_BUILD_CONFIG_H_ diff --git a/sdk/include/cppconn/config.h b/sdk/include/cppconn/config.h new file mode 100644 index 0000000..f197a02 --- /dev/null +++ b/sdk/include/cppconn/config.h @@ -0,0 +1,90 @@ +/* + Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPL + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPL as it is applied to this software, see the + FLOSS License Exception + . +*/ + +// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names +// to avoid annoying warnings. + +#define HAVE_FUNCTION_STRTOLD 1 +#define HAVE_FUNCTION_STRTOLL 1 +#define HAVE_FUNCTION_STRTOL 1 +#define HAVE_FUNCTION_STRTOULL 1 + +#define HAVE_FUNCTION_STRTOUL 1 + +#define HAVE_FUNCTION_STRTOIMAX 1 +#define HAVE_FUNCTION_STRTOUMAX 1 + +#define HAVE_STDINT_H 1 +#define HAVE_INTTYPES_H 1 + +#define HAVE_INT8_T 1 +#define HAVE_UINT8_T 1 +#define HAVE_INT16_T 1 +#define HAVE_UINT16_T 1 +#define HAVE_INT32_T 1 +#define HAVE_UINT32_T 1 +#define HAVE_INT32_T 1 +#define HAVE_UINT32_T 1 +#define HAVE_INT64_T 1 +#define HAVE_UINT64_T 1 +/* #undef HAVE_MS_INT8 */ +/* #undef HAVE_MS_UINT8 */ +/* #undef HAVE_MS_INT16 */ +/* #undef HAVE_MS_UINT16 */ +/* #undef HAVE_MS_INT32 */ +/* #undef HAVE_MS_UINT32 */ +/* #undef HAVE_MS_INT64 */ +/* #undef HAVE_MS_UINT64 */ + + +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_INTTYPES_H +#include +#endif + +#if defined(_WIN32) +#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES + +#if !defined(HAVE_INT8_T) && defined(HAVE_MS_INT8) +typedef __int8 int8_t; +#endif + +#ifdef HAVE_MS_UINT8 +typedef unsigned __int8 uint8_t; +#endif +#ifdef HAVE_MS_INT16 +typedef __int16 int16_t; +#endif + +#ifdef HAVE_MS_UINT16 +typedef unsigned __int16 uint16_t; +#endif + +#ifdef HAVE_MS_INT32 +typedef __int32 int32_t; +#endif + +#ifdef HAVE_MS_UINT32 +typedef unsigned __int32 uint32_t; +#endif + +#ifdef HAVE_MS_INT64 +typedef __int64 int64_t; +#endif +#ifdef HAVE_MS_UINT64 +typedef unsigned __int64 uint64_t; +#endif + +#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES +#endif // _WIN32 diff --git a/sdk/include/cppconn/connection.h b/sdk/include/cppconn/connection.h new file mode 100644 index 0000000..aab4e9a --- /dev/null +++ b/sdk/include/cppconn/connection.h @@ -0,0 +1,155 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_CONNECTION_H_ +#define _SQL_CONNECTION_H_ + +#include +#include + +#include "build_config.h" +#include "warning.h" +#include "sqlstring.h" + +namespace sql +{ + + +typedef boost::variant ConnectPropertyVal; + +typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap; + +class DatabaseMetaData; +class PreparedStatement; +class Statement; +class Driver; + +typedef enum transaction_isolation +{ + TRANSACTION_NONE= 0, + TRANSACTION_READ_COMMITTED, + TRANSACTION_READ_UNCOMMITTED, + TRANSACTION_REPEATABLE_READ, + TRANSACTION_SERIALIZABLE +} enum_transaction_isolation; + +class Savepoint +{ + /* Prevent use of these */ + Savepoint(const Savepoint &); + void operator=(Savepoint &); +public: + Savepoint() {}; + virtual ~Savepoint() {}; + virtual int getSavepointId() = 0; + + virtual sql::SQLString getSavepointName() = 0; +}; + + +class CPPCONN_PUBLIC_FUNC Connection +{ + /* Prevent use of these */ + Connection(const Connection &); + void operator=(Connection &); +public: + + Connection() {}; + + virtual ~Connection() {}; + + virtual void clearWarnings() = 0; + + virtual Statement *createStatement() = 0; + + virtual void close() = 0; + + virtual void commit() = 0; + + virtual bool getAutoCommit() = 0; + + virtual sql::SQLString getCatalog() = 0; + + virtual Driver *getDriver() = 0; + + virtual sql::SQLString getSchema() = 0; + + virtual sql::SQLString getClientInfo() = 0; + + virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0; + + virtual DatabaseMetaData * getMetaData() = 0; + + virtual enum_transaction_isolation getTransactionIsolation() = 0; + + virtual const SQLWarning * getWarnings() = 0; + + virtual bool isClosed() = 0; + + virtual bool isReadOnly() = 0; + + virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0; + + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0; + + virtual void releaseSavepoint(Savepoint * savepoint) = 0; + + virtual void rollback() = 0; + + virtual void rollback(Savepoint * savepoint) = 0; + + virtual void setAutoCommit(bool autoCommit) = 0; + + virtual void setCatalog(const sql::SQLString& catalog) = 0; + + virtual void setSchema(const sql::SQLString& catalog) = 0; + + virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0; + + virtual void setHoldability(int holdability) = 0; + + virtual void setReadOnly(bool readOnly) = 0; + + virtual Savepoint * setSavepoint() = 0; + + virtual Savepoint * setSavepoint(const sql::SQLString& name) = 0; + + virtual void setTransactionIsolation(enum_transaction_isolation level) = 0; + + /* virtual void setTypeMap(Map map) = 0; */ +}; + +} /* namespace sql */ + +#endif // _SQL_CONNECTION_H_ diff --git a/sdk/include/cppconn/datatype.h b/sdk/include/cppconn/datatype.h new file mode 100644 index 0000000..b177b05 --- /dev/null +++ b/sdk/include/cppconn/datatype.h @@ -0,0 +1,66 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_DATATYPE_H_ +#define _SQL_DATATYPE_H_ + +namespace sql +{ + +class DataType +{ + DataType(); +public: + enum { + UNKNOWN = 0, + BIT, + TINYINT, + SMALLINT, + MEDIUMINT, + INTEGER, + BIGINT, + REAL, + DOUBLE, + DECIMAL, + NUMERIC, + CHAR, + BINARY, + VARCHAR, + VARBINARY, + LONGVARCHAR, + LONGVARBINARY, + TIMESTAMP, + DATE, + TIME, + YEAR, + GEOMETRY, + ENUM, + SET, + SQLNULL + }; +}; + +} /* namespace */ + +#endif /* _SQL_DATATYPE_H_ */ diff --git a/sdk/include/cppconn/driver.h b/sdk/include/cppconn/driver.h new file mode 100644 index 0000000..7ec7e42 --- /dev/null +++ b/sdk/include/cppconn/driver.h @@ -0,0 +1,68 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_DRIVER_H_ +#define _SQL_DRIVER_H_ + +#include "connection.h" +#include "build_config.h" + +namespace sql +{ + +class CPPCONN_PUBLIC_FUNC Driver +{ +protected: + virtual ~Driver() {} +public: + // Attempts to make a database connection to the given URL. + + virtual Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password) = 0; + + virtual Connection * connect(ConnectOptionsMap & options) = 0; + + virtual int getMajorVersion() = 0; + + virtual int getMinorVersion() = 0; + + virtual int getPatchVersion() = 0; + + virtual const sql::SQLString & getName() = 0; + + virtual void threadInit() = 0; + + virtual void threadEnd() = 0; +}; + +} /* namespace sql */ + +extern "C" +{ + CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance(); + + /* If dynamic loading is disabled in a driver then this function works just like get_driver_instance() */ + CPPCONN_PUBLIC_FUNC sql::Driver * get_driver_instance_by_name(const char * const clientlib); +} + +#endif /* _SQL_DRIVER_H_ */ diff --git a/sdk/include/cppconn/exception.h b/sdk/include/cppconn/exception.h new file mode 100644 index 0000000..0945efc --- /dev/null +++ b/sdk/include/cppconn/exception.h @@ -0,0 +1,126 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_EXCEPTION_H_ +#define _SQL_EXCEPTION_H_ + +#include "build_config.h" +#include +#include +#include + +namespace sql +{ + +#define MEMORY_ALLOC_OPERATORS(Class) \ + void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \ + void* operator new(size_t, void*) throw(); \ + void* operator new(size_t, const std::nothrow_t&) throw(); \ + void* operator new[](size_t) throw (std::bad_alloc); \ + void* operator new[](size_t, void*) throw(); \ + void* operator new[](size_t, const std::nothrow_t&) throw(); \ + void* operator new(size_t N, std::allocator&); + +#ifdef _WIN32 +#pragma warning (disable : 4290) +//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) + + +#pragma warning(push) +#pragma warning(disable: 4275) +#endif +class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error +{ +#ifdef _WIN32 +#pragma warning(pop) +#endif +protected: + const std::string sql_state; + const int errNo; + +public: + SQLException(const SQLException& e) : std::runtime_error(e.what()), sql_state(e.sql_state), errNo(e.errNo) {} + + SQLException(const std::string& reason, const std::string& SQLState, int vendorCode) : + std::runtime_error (reason ), + sql_state (SQLState ), + errNo (vendorCode) + {} + + SQLException(const std::string& reason, const std::string& SQLState) : std::runtime_error(reason), sql_state(SQLState), errNo(0) {} + + SQLException(const std::string& reason) : std::runtime_error(reason), sql_state("HY000"), errNo(0) {} + + SQLException() : std::runtime_error(""), sql_state("HY000"), errNo(0) {} + + const std::string & getSQLState() const + { + return sql_state; + } + + const char * getSQLStateCStr() const + { + return sql_state.c_str(); + } + + + int getErrorCode() const + { + return errNo; + } + + virtual ~SQLException() throw () {}; + +protected: + MEMORY_ALLOC_OPERATORS(SQLException) +}; + +struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException +{ + MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } + MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {} +}; + +struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException +{ + InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } + InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {} +}; + +struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException +{ + InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } + InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {} +}; + + +struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException +{ + NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { } + NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {} +}; + +} /* namespace sql */ + +#endif /* _SQL_EXCEPTION_H_ */ diff --git a/sdk/include/cppconn/metadata.h b/sdk/include/cppconn/metadata.h new file mode 100644 index 0000000..33f381e --- /dev/null +++ b/sdk/include/cppconn/metadata.h @@ -0,0 +1,477 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_METADATA_H_ +#define _SQL_METADATA_H_ + +#include +#include +#include "datatype.h" +#include "sqlstring.h" + +namespace sql +{ +class ResultSet; + +class DatabaseMetaData +{ +protected: + virtual ~DatabaseMetaData() {} + +public: + enum + { + attributeNoNulls = 0, + attributeNullable, + attributeNullableUnknown + }; + enum + { + bestRowTemporary = 0, + bestRowTransaction, + bestRowSession + }; + enum + { + bestRowUnknown = 0, + bestRowNotPseudo, + bestRowPseudo + }; + enum + { + columnNoNulls = 0, + columnNullable, + columnNullableUnknown + }; + enum + { + importedKeyCascade = 0, + importedKeyInitiallyDeferred, + importedKeyInitiallyImmediate, + importedKeyNoAction, + importedKeyNotDeferrable, + importedKeyRestrict, + importedKeySetDefault, + importedKeySetNull + }; + enum + { + procedureColumnIn = 0, + procedureColumnInOut, + procedureColumnOut, + procedureColumnResult, + procedureColumnReturn, + procedureColumnUnknown, + procedureNoNulls, + procedureNoResult, + procedureNullable, + procedureNullableUnknown, + procedureResultUnknown, + procedureReturnsResult + }; + enum + { + sqlStateSQL99 = 0, + sqlStateXOpen + }; + enum + { + tableIndexClustered = 0, + tableIndexHashed, + tableIndexOther, + tableIndexStatistic + }; + enum + { + versionColumnUnknown = 0, + versionColumnNotPseudo = 1, + versionColumnPseudo = 2 + }; + enum + { + typeNoNulls = 0, + typeNullable = 1, + typeNullableUnknown = 2 + }; + enum + { + typePredNone = 0, + typePredChar = 1, + typePredBasic= 2, + typeSearchable = 3 + }; + + + virtual bool allProceduresAreCallable() = 0; + + virtual bool allTablesAreSelectable() = 0; + + virtual bool dataDefinitionCausesTransactionCommit() = 0; + + virtual bool dataDefinitionIgnoredInTransactions() = 0; + + virtual bool deletesAreDetected(int type) = 0; + + virtual bool doesMaxRowSizeIncludeBlobs() = 0; + + virtual ResultSet * getAttributes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, const sql::SQLString& attributeNamePattern) = 0; + + virtual ResultSet * getBestRowIdentifier(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, int scope, bool nullable) = 0; + + virtual ResultSet * getCatalogs() = 0; + + virtual const sql::SQLString& getCatalogSeparator() = 0; + + virtual const sql::SQLString& getCatalogTerm() = 0; + + virtual ResultSet * getColumnPrivileges(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, const sql::SQLString& columnNamePattern) = 0; + + virtual ResultSet * getColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, const sql::SQLString& columnNamePattern) = 0; + + virtual Connection * getConnection() = 0; + + virtual ResultSet * getCrossReference(const sql::SQLString& primaryCatalog, const sql::SQLString& primarySchema, const sql::SQLString& primaryTable, const sql::SQLString& foreignCatalog, const sql::SQLString& foreignSchema, const sql::SQLString& foreignTable) = 0; + + virtual unsigned int getDatabaseMajorVersion() = 0; + + virtual unsigned int getDatabaseMinorVersion() = 0; + + virtual unsigned int getDatabasePatchVersion() = 0; + + virtual const sql::SQLString& getDatabaseProductName() = 0; + + virtual SQLString getDatabaseProductVersion() = 0; + + virtual int getDefaultTransactionIsolation() = 0; + + virtual unsigned int getDriverMajorVersion() = 0; + + virtual unsigned int getDriverMinorVersion() = 0; + + virtual unsigned int getDriverPatchVersion() = 0; + + virtual const sql::SQLString& getDriverName() = 0; + + virtual const sql::SQLString& getDriverVersion() = 0; + + virtual ResultSet * getExportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0; + + virtual const sql::SQLString& getExtraNameCharacters() = 0; + + virtual const sql::SQLString& getIdentifierQuoteString() = 0; + + virtual ResultSet * getImportedKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0; + + virtual ResultSet * getIndexInfo(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table, bool unique, bool approximate) = 0; + + virtual unsigned int getCDBCMajorVersion() = 0; + + virtual unsigned int getCDBCMinorVersion() = 0; + + virtual unsigned int getMaxBinaryLiteralLength() = 0; + + virtual unsigned int getMaxCatalogNameLength() = 0; + + virtual unsigned int getMaxCharLiteralLength() = 0; + + virtual unsigned int getMaxColumnNameLength() = 0; + + virtual unsigned int getMaxColumnsInGroupBy() = 0; + + virtual unsigned int getMaxColumnsInIndex() = 0; + + virtual unsigned int getMaxColumnsInOrderBy() = 0; + + virtual unsigned int getMaxColumnsInSelect() = 0; + + virtual unsigned int getMaxColumnsInTable() = 0; + + virtual unsigned int getMaxConnections() = 0; + + virtual unsigned int getMaxCursorNameLength() = 0; + + virtual unsigned int getMaxIndexLength() = 0; + + virtual unsigned int getMaxProcedureNameLength() = 0; + + virtual unsigned int getMaxRowSize() = 0; + + virtual unsigned int getMaxSchemaNameLength() = 0; + + virtual unsigned int getMaxStatementLength() = 0; + + virtual unsigned int getMaxStatements() = 0; + + virtual unsigned int getMaxTableNameLength() = 0; + + virtual unsigned int getMaxTablesInSelect() = 0; + + virtual unsigned int getMaxUserNameLength() = 0; + + virtual const sql::SQLString& getNumericFunctions() = 0; + + virtual ResultSet * getPrimaryKeys(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0; + + virtual ResultSet * getProcedureColumns(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern, const sql::SQLString& columnNamePattern) = 0; + + virtual ResultSet * getProcedures(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& procedureNamePattern) = 0; + + virtual const sql::SQLString& getProcedureTerm() = 0; + + virtual int getResultSetHoldability() = 0; + + virtual ResultSet * getSchemas() = 0; + + virtual const sql::SQLString& getSchemaTerm() = 0; + + virtual const sql::SQLString& getSearchStringEscape() = 0; + + virtual const sql::SQLString& getSQLKeywords() = 0; + + virtual int getSQLStateType() = 0; + + virtual const sql::SQLString& getStringFunctions() = 0; + + virtual ResultSet * getSuperTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0; + + virtual ResultSet * getSuperTypes(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern) = 0; + + virtual const sql::SQLString& getSystemFunctions() = 0; + + virtual ResultSet * getTablePrivileges(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern) = 0; + + virtual ResultSet * getTables(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& tableNamePattern, std::list &types) = 0; + + virtual ResultSet * getTableTypes() = 0; + + virtual const sql::SQLString& getTimeDateFunctions() = 0; + + virtual ResultSet * getTypeInfo() = 0; + + virtual ResultSet * getUDTs(const sql::SQLString& catalog, const sql::SQLString& schemaPattern, const sql::SQLString& typeNamePattern, std::list &types) = 0; + + virtual SQLString getURL() = 0; + + virtual SQLString getUserName() = 0; + + virtual ResultSet * getVersionColumns(const sql::SQLString& catalog, const sql::SQLString& schema, const sql::SQLString& table) = 0; + + virtual bool insertsAreDetected(int type) = 0; + + virtual bool isCatalogAtStart() = 0; + + virtual bool isReadOnly() = 0; + + virtual bool locatorsUpdateCopy() = 0; + + virtual bool nullPlusNonNullIsNull() = 0; + + virtual bool nullsAreSortedAtEnd() = 0; + + virtual bool nullsAreSortedAtStart() = 0; + + virtual bool nullsAreSortedHigh() = 0; + + virtual bool nullsAreSortedLow() = 0; + + virtual bool othersDeletesAreVisible(int type) = 0; + + virtual bool othersInsertsAreVisible(int type) = 0; + + virtual bool othersUpdatesAreVisible(int type) = 0; + + virtual bool ownDeletesAreVisible(int type) = 0; + + virtual bool ownInsertsAreVisible(int type) = 0; + + virtual bool ownUpdatesAreVisible(int type) = 0; + + virtual bool storesLowerCaseIdentifiers() = 0; + + virtual bool storesLowerCaseQuotedIdentifiers() = 0; + + virtual bool storesMixedCaseIdentifiers() = 0; + + virtual bool storesMixedCaseQuotedIdentifiers() = 0; + + virtual bool storesUpperCaseIdentifiers() = 0; + + virtual bool storesUpperCaseQuotedIdentifiers() = 0; + + virtual bool supportsAlterTableWithAddColumn() = 0; + + virtual bool supportsAlterTableWithDropColumn() = 0; + + virtual bool supportsANSI92EntryLevelSQL() = 0; + + virtual bool supportsANSI92FullSQL() = 0; + + virtual bool supportsANSI92IntermediateSQL() = 0; + + virtual bool supportsBatchUpdates() = 0; + + virtual bool supportsCatalogsInDataManipulation() = 0; + + virtual bool supportsCatalogsInIndexDefinitions() = 0; + + virtual bool supportsCatalogsInPrivilegeDefinitions() = 0; + + virtual bool supportsCatalogsInProcedureCalls() = 0; + + virtual bool supportsCatalogsInTableDefinitions() = 0; + + virtual bool supportsColumnAliasing() = 0; + + virtual bool supportsConvert() = 0; + + virtual bool supportsConvert(int fromType, int toType) = 0; + + virtual bool supportsCoreSQLGrammar() = 0; + + virtual bool supportsCorrelatedSubqueries() = 0; + + virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0; + + virtual bool supportsDataManipulationTransactionsOnly() = 0; + + virtual bool supportsDifferentTableCorrelationNames() = 0; + + virtual bool supportsExpressionsInOrderBy() = 0; + + virtual bool supportsExtendedSQLGrammar() = 0; + + virtual bool supportsFullOuterJoins() = 0; + + virtual bool supportsGetGeneratedKeys() = 0; + + virtual bool supportsGroupBy() = 0; + + virtual bool supportsGroupByBeyondSelect() = 0; + + virtual bool supportsGroupByUnrelated() = 0; + + virtual bool supportsIntegrityEnhancementFacility() = 0; + + virtual bool supportsLikeEscapeClause() = 0; + + virtual bool supportsLimitedOuterJoins() = 0; + + virtual bool supportsMinimumSQLGrammar() = 0; + + virtual bool supportsMixedCaseIdentifiers() = 0; + + virtual bool supportsMixedCaseQuotedIdentifiers() = 0; + + virtual bool supportsMultipleOpenResults() = 0; + + virtual bool supportsMultipleResultSets() = 0; + + virtual bool supportsMultipleTransactions() = 0; + + virtual bool supportsNamedParameters() = 0; + + virtual bool supportsNonNullableColumns() = 0; + + virtual bool supportsOpenCursorsAcrossCommit() = 0; + + virtual bool supportsOpenCursorsAcrossRollback() = 0; + + virtual bool supportsOpenStatementsAcrossCommit() = 0; + + virtual bool supportsOpenStatementsAcrossRollback() = 0; + + virtual bool supportsOrderByUnrelated() = 0; + + virtual bool supportsOuterJoins() = 0; + + virtual bool supportsPositionedDelete() = 0; + + virtual bool supportsPositionedUpdate() = 0; + + virtual bool supportsResultSetConcurrency(int type, int concurrency) = 0; + + virtual bool supportsResultSetHoldability(int holdability) = 0; + + virtual bool supportsResultSetType(int type) = 0; + + virtual bool supportsSavepoints() = 0; + + virtual bool supportsSchemasInDataManipulation() = 0; + + virtual bool supportsSchemasInIndexDefinitions() = 0; + + virtual bool supportsSchemasInPrivilegeDefinitions() = 0; + + virtual bool supportsSchemasInProcedureCalls() = 0; + + virtual bool supportsSchemasInTableDefinitions() = 0; + + virtual bool supportsSelectForUpdate() = 0; + + virtual bool supportsStatementPooling() = 0; + + virtual bool supportsStoredProcedures() = 0; + + virtual bool supportsSubqueriesInComparisons() = 0; + + virtual bool supportsSubqueriesInExists() = 0; + + virtual bool supportsSubqueriesInIns() = 0; + + virtual bool supportsSubqueriesInQuantifieds() = 0; + + virtual bool supportsTableCorrelationNames() = 0; + + virtual bool supportsTransactionIsolationLevel(int level) = 0; + + virtual bool supportsTransactions() = 0; + + virtual bool supportsTypeConversion() = 0; /* SDBC */ + + virtual bool supportsUnion() = 0; + + virtual bool supportsUnionAll() = 0; + + virtual bool updatesAreDetected(int type) = 0; + + virtual bool usesLocalFilePerTable() = 0; + + virtual bool usesLocalFiles() = 0; + + virtual ResultSet *getSchemata(const sql::SQLString& catalogName = "") = 0; + + virtual ResultSet *getSchemaObjects(const sql::SQLString& catalogName = "", + const sql::SQLString& schemaName = "", + const sql::SQLString& objectType = "", + bool includingDdl = true, + const sql::SQLString& objectName = "", + const sql::SQLString& contextTableName = "") = 0; + + virtual ResultSet *getSchemaObjectTypes() = 0; +}; + + +} /* namespace sql */ + +#endif /* _SQL_METADATA_H_ */ diff --git a/sdk/include/cppconn/parameter_metadata.h b/sdk/include/cppconn/parameter_metadata.h new file mode 100644 index 0000000..7e97f4c --- /dev/null +++ b/sdk/include/cppconn/parameter_metadata.h @@ -0,0 +1,76 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_PARAMETER_METADATA_H_ +#define _SQL_PARAMETER_METADATA_H_ + +#include + + +namespace sql +{ + +class ParameterMetaData +{ +public: + enum + { + parameterModeIn, + parameterModeInOut, + parameterModeOut, + parameterModeUnknown + }; + enum + { + parameterNoNulls, + parameterNullable, + parameterNullableUnknown + }; + + virtual sql::SQLString getParameterClassName(unsigned int param) = 0; + + virtual int getParameterCount() = 0; + + virtual int getParameterMode(unsigned int param) = 0; + + virtual int getParameterType(unsigned int param) = 0; + + virtual sql::SQLString getParameterTypeName(unsigned int param) = 0; + + virtual int getPrecision(unsigned int param) = 0; + + virtual int getScale(unsigned int param) = 0; + + virtual int isNullable(unsigned int param) = 0; + + virtual bool isSigned(unsigned int param) = 0; + +protected: + virtual ~ParameterMetaData() {} +}; + + +} /* namespace sql */ + +#endif /* _SQL_PARAMETER_METADATA_H_ */ diff --git a/sdk/include/cppconn/prepared_statement.h b/sdk/include/cppconn/prepared_statement.h new file mode 100644 index 0000000..5549651 --- /dev/null +++ b/sdk/include/cppconn/prepared_statement.h @@ -0,0 +1,89 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + + +#ifndef _SQL_PREPARED_STATEMENT_H_ +#define _SQL_PREPARED_STATEMENT_H_ + +#include +#include "statement.h" + + +namespace sql +{ + +class Connection; +class ResultSet; +class ResultSetMetaData; +class ParameterMetaData; + +class PreparedStatement : public Statement +{ +public: + virtual ~PreparedStatement() {} + + virtual void clearParameters() = 0; + + virtual bool execute(const sql::SQLString& sql) = 0; + virtual bool execute() = 0; + + virtual ResultSet *executeQuery(const sql::SQLString& sql) = 0; + virtual ResultSet *executeQuery() = 0; + + virtual int executeUpdate(const sql::SQLString& sql) = 0; + virtual int executeUpdate() = 0; + + virtual ResultSetMetaData * getMetaData() = 0; + + virtual ParameterMetaData * getParameterMetaData() = 0; + + virtual void setBigInt(unsigned int parameterIndex, const sql::SQLString& value) = 0; + + virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0; + + virtual void setBoolean(unsigned int parameterIndex, bool value) = 0; + + virtual void setDateTime(unsigned int parameterIndex, const sql::SQLString& value) = 0; + + virtual void setDouble(unsigned int parameterIndex, double value) = 0; + + virtual void setInt(unsigned int parameterIndex, int32_t value) = 0; + + virtual void setUInt(unsigned int parameterIndex, uint32_t value) = 0; + + virtual void setInt64(unsigned int parameterIndex, int64_t value) = 0; + + virtual void setUInt64(unsigned int parameterIndex, uint64_t value) = 0; + + virtual void setNull(unsigned int parameterIndex, int sqlType) = 0; + + virtual void setString(unsigned int parameterIndex, const sql::SQLString& value) = 0; + + virtual PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) = 0; +}; + + +} /* namespace sql */ + +#endif /* _SQL_PREPARED_STATEMENT_H_ */ diff --git a/sdk/include/cppconn/resultset.h b/sdk/include/cppconn/resultset.h new file mode 100644 index 0000000..d4f207a --- /dev/null +++ b/sdk/include/cppconn/resultset.h @@ -0,0 +1,180 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_RESULTSET_H_ +#define _SQL_RESULTSET_H_ + +#include "config.h" + +#include +#include +#include +#include "sqlstring.h" +#include "resultset_metadata.h" + + +namespace sql +{ + +class Statement; + +class RowID +{ +public: + virtual ~RowID() {} +}; + +class ResultSet +{ +public: + enum + { + CLOSE_CURSORS_AT_COMMIT, + HOLD_CURSORS_OVER_COMMIT + }; + enum + { + CONCUR_READ_ONLY, + CONCUR_UPDATABLE + }; + enum + { + FETCH_FORWARD, + FETCH_REVERSE, + FETCH_UNKNOWN + }; + typedef enum + { + TYPE_FORWARD_ONLY, + TYPE_SCROLL_INSENSITIVE, + TYPE_SCROLL_SENSITIVE + } enum_type; + + virtual ~ResultSet() {} + + virtual bool absolute(int row) = 0; + + virtual void afterLast() = 0; + + virtual void beforeFirst() = 0; + + virtual void cancelRowUpdates() = 0; + + virtual void clearWarnings() = 0; + + virtual void close() = 0; + + virtual uint32_t findColumn(const sql::SQLString& columnLabel) const = 0; + + virtual bool first() = 0; + + virtual std::istream * getBlob(uint32_t columnIndex) const = 0; + virtual std::istream * getBlob(const sql::SQLString& columnLabel) const = 0; + + virtual bool getBoolean(uint32_t columnIndex) const = 0; + virtual bool getBoolean(const sql::SQLString& columnLabel) const = 0; + + virtual int getConcurrency() = 0; + virtual SQLString getCursorName() = 0; + + virtual long double getDouble(uint32_t columnIndex) const = 0; + virtual long double getDouble(const sql::SQLString& columnLabel) const = 0; + + virtual int getFetchDirection() = 0; + virtual size_t getFetchSize() = 0; + virtual int getHoldability() = 0; + + virtual int32_t getInt(uint32_t columnIndex) const = 0; + virtual int32_t getInt(const sql::SQLString& columnLabel) const = 0; + + virtual uint32_t getUInt(uint32_t columnIndex) const = 0; + virtual uint32_t getUInt(const sql::SQLString& columnLabel) const = 0; + + virtual int64_t getInt64(uint32_t columnIndex) const = 0; + virtual int64_t getInt64(const sql::SQLString& columnLabel) const = 0; + + virtual uint64_t getUInt64(uint32_t columnIndex) const = 0; + virtual uint64_t getUInt64(const sql::SQLString& columnLabel) const = 0; + + virtual ResultSetMetaData * getMetaData() const = 0; + + virtual size_t getRow() const = 0; + + virtual RowID * getRowId(uint32_t columnIndex) = 0; + virtual RowID * getRowId(const sql::SQLString & columnLabel) = 0; + + virtual const Statement * getStatement() const = 0; + + virtual SQLString getString(uint32_t columnIndex) const = 0; + virtual SQLString getString(const sql::SQLString& columnLabel) const = 0; + + virtual enum_type getType() const = 0; + + virtual void getWarnings() = 0; + + virtual void insertRow() = 0; + + virtual bool isAfterLast() const = 0; + + virtual bool isBeforeFirst() const = 0; + + virtual bool isClosed() const = 0; + + virtual bool isFirst() const = 0; + + virtual bool isLast() const = 0; + + virtual bool isNull(uint32_t columnIndex) const = 0; + virtual bool isNull(const sql::SQLString& columnLabel) const = 0; + + virtual bool last() = 0; + + virtual bool next() = 0; + + virtual void moveToCurrentRow() = 0; + + virtual void moveToInsertRow() = 0; + + virtual bool previous() = 0; + + virtual void refreshRow() = 0; + + virtual bool relative(int rows) = 0; + + virtual bool rowDeleted() = 0; + + virtual bool rowInserted() = 0; + + virtual bool rowUpdated() = 0; + + virtual void setFetchSize(size_t rows) = 0; + + virtual size_t rowsCount() const = 0; + + virtual bool wasNull() const = 0; +}; + +} /* namespace sql */ + +#endif /* _SQL_RESULTSET_H_ */ diff --git a/sdk/include/cppconn/resultset_metadata.h b/sdk/include/cppconn/resultset_metadata.h new file mode 100644 index 0000000..f23e34c --- /dev/null +++ b/sdk/include/cppconn/resultset_metadata.h @@ -0,0 +1,93 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_RESULTSET_METADATA_H_ +#define _SQL_RESULTSET_METADATA_H_ + +#include "sqlstring.h" +#include "datatype.h" + +namespace sql +{ + +class ResultSetMetaData +{ +public: + enum + { + columnNoNulls, + columnNullable, + columnNullableUnknown + }; + + virtual SQLString getCatalogName(unsigned int column) = 0; + + virtual unsigned int getColumnCount() = 0; + + virtual unsigned int getColumnDisplaySize(unsigned int column) = 0; + + virtual SQLString getColumnLabel(unsigned int column) = 0; + + virtual SQLString getColumnName(unsigned int column) = 0; + + virtual int getColumnType(unsigned int column) = 0; + + virtual SQLString getColumnTypeName(unsigned int column) = 0; + + virtual unsigned int getPrecision(unsigned int column) = 0; + + virtual unsigned int getScale(unsigned int column) = 0; + + virtual SQLString getSchemaName(unsigned int column) = 0; + + virtual SQLString getTableName(unsigned int column) = 0; + + virtual bool isAutoIncrement(unsigned int column) = 0; + + virtual bool isCaseSensitive(unsigned int column) = 0; + + virtual bool isCurrency(unsigned int column) = 0; + + virtual bool isDefinitelyWritable(unsigned int column) = 0; + + virtual int isNullable(unsigned int column) = 0; + + virtual bool isReadOnly(unsigned int column) = 0; + + virtual bool isSearchable(unsigned int column) = 0; + + virtual bool isSigned(unsigned int column) = 0; + + virtual bool isWritable(unsigned int column) = 0; + + virtual bool isZerofill(unsigned int column) = 0; + +protected: + virtual ~ResultSetMetaData() {} +}; + + +} /* namespace sql */ + +#endif /* _SQL_RESULTSET_METADATA_H_ */ diff --git a/sdk/include/cppconn/sqlstring.h b/sdk/include/cppconn/sqlstring.h new file mode 100644 index 0000000..24577d3 --- /dev/null +++ b/sdk/include/cppconn/sqlstring.h @@ -0,0 +1,211 @@ +/* + Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_STRING_H_ +#define _SQL_STRING_H_ + +#include +#include "build_config.h" +#include + +namespace sql +{ + class CPPCONN_PUBLIC_FUNC SQLString + { + std::string realStr; + + public: +#ifdef _WIN32 + //TODO something less dirty-hackish. + static const size_t npos = static_cast(-1); +#else + static const size_t npos = std::string::npos; +#endif + + ~SQLString() {} + + SQLString() {} + + SQLString(const SQLString & other) : realStr(other.realStr) {} + + SQLString(const std::string & other) : realStr(other) {} + + SQLString(const char other[]) : realStr(other) {} + + SQLString(const char * s, size_t n) : realStr(s, n) {} + + // Needed for stuff like SQLString str= "char * string constant" + const SQLString & operator=(const char * s) + { + realStr = s; + return *this; + } + + const SQLString & operator=(const std::string & rhs) + { + realStr = rhs; + return *this; + } + + const SQLString & operator=(const SQLString & rhs) + { + realStr = rhs.realStr; + return *this; + } + + // Conversion to st::string. Comes in play for stuff like std::string str= SQLString_var; + operator const std::string &() const + { + return realStr; + } + + /** For access std::string methods. Not sure we need it. Makes it look like some smart ptr. + possibly operator* - will look even more like smart ptr */ + std::string * operator ->() + { + return & realStr; + } + + int compare(const SQLString& str) const + { + return realStr.compare(str.realStr); + } + + int compare(const char * s) const + { + return realStr.compare(s); + } + + int compare(size_t pos1, size_t n1, const char * s) const + { + return realStr.compare(pos1, n1, s); + } + + const std::string & asStdString() const + { + return realStr; + } + + const char * c_str() const + { + return realStr.c_str(); + } + + size_t length() const + { + return realStr.length(); + } + + SQLString & append(const std::string & str) + { + realStr.append(str); + return *this; + } + + SQLString & append(const char * s) + { + realStr.append(s); + return *this; + } + + const char& operator[](size_t pos) const + { + return realStr[pos]; + } + + size_t find(char c, size_t pos = 0) const + { + return realStr.find(c, pos); + } + + size_t find(const SQLString & s, size_t pos = 0) const + { + return realStr.find(s.realStr, pos); + } + + SQLString substr(size_t pos = 0, size_t n = npos) const + { + return realStr.substr(pos, n); + } + + const SQLString& replace(size_t pos1, size_t n1, const SQLString & s) + { + realStr.replace(pos1, n1, s.realStr); + return *this; + } + + size_t find_first_of(char c, size_t pos = 0) const + { + return realStr.find_first_of(c, pos); + } + + size_t find_last_of(char c, size_t pos = npos) const + { + return realStr.find_last_of(c, pos); + } + + const SQLString & operator+=(const SQLString & op2) + { + realStr += op2.realStr; + return *this; + } +}; + + +/* + Operators that can and have to be not a member. +*/ +inline const SQLString operator+(const SQLString & op1, const SQLString & op2) +{ + return sql::SQLString(op1.asStdString() + op2.asStdString()); +} + +inline bool operator ==(const SQLString & op1, const SQLString & op2) +{ + return (op1.asStdString() == op2.asStdString()); +} + +inline bool operator !=(const SQLString & op1, const SQLString & op2) +{ + return (op1.asStdString() != op2.asStdString()); +} + +inline bool operator <(const SQLString & op1, const SQLString & op2) +{ + return op1.asStdString() < op2.asStdString(); +} + + +}// namespace sql + + +namespace std +{ + // operator << for SQLString output + inline ostream & operator << (ostream & os, const sql::SQLString & str ) + { + return os << str.asStdString(); + } +} +#endif diff --git a/sdk/include/cppconn/statement.h b/sdk/include/cppconn/statement.h new file mode 100644 index 0000000..92406a0 --- /dev/null +++ b/sdk/include/cppconn/statement.h @@ -0,0 +1,95 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_STATEMENT_H_ +#define _SQL_STATEMENT_H_ + +#include "config.h" +#include "resultset.h" + +#include + +namespace sql +{ + +class ResultSet; +class Connection; +class SQLWarning; + + +class Statement +{ +public: + virtual ~Statement() {}; + + virtual Connection * getConnection() = 0; + + virtual void cancel() = 0; + + virtual void clearWarnings() = 0; + + virtual void close() = 0; + + virtual bool execute(const sql::SQLString& sql) = 0; + + virtual ResultSet * executeQuery(const sql::SQLString& sql) = 0; + + virtual int executeUpdate(const sql::SQLString& sql) = 0; + + virtual size_t getFetchSize() = 0; + + virtual unsigned int getMaxFieldSize() = 0; + + virtual uint64_t getMaxRows() = 0; + + virtual bool getMoreResults() = 0; + + virtual unsigned int getQueryTimeout() = 0; + + virtual ResultSet * getResultSet() = 0; + + virtual sql::ResultSet::enum_type getResultSetType() = 0; + + virtual uint64_t getUpdateCount() = 0; + + virtual const SQLWarning * getWarnings() = 0; + + virtual void setCursorName(const sql::SQLString & name) = 0; + + virtual void setEscapeProcessing(bool enable) = 0; + + virtual void setFetchSize(size_t rows) = 0; + + virtual void setMaxFieldSize(unsigned int max) = 0; + + virtual void setMaxRows(unsigned int max) = 0; + + virtual void setQueryTimeout(unsigned int seconds) = 0; + + virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0; +}; + +} /* namespace sql */ + +#endif /* _SQL_STATEMENT_H_ */ diff --git a/sdk/include/cppconn/warning.h b/sdk/include/cppconn/warning.h new file mode 100644 index 0000000..05dc471 --- /dev/null +++ b/sdk/include/cppconn/warning.h @@ -0,0 +1,72 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _SQL_WARNING_H_ +#define _SQL_WARNING_H_ + + +#include +#include +#include +#include "sqlstring.h" + +namespace sql +{ + +#ifdef _WIN32 +#pragma warning (disable : 4290) +//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif + +class SQLWarning +{ +public: + + SQLWarning(){} + + virtual const sql::SQLString & getMessage() const = 0; + + virtual const sql::SQLString & getSQLState() const = 0; + + virtual int getErrorCode() const = 0; + + virtual const SQLWarning * getNextWarning() const = 0; + + virtual void setNextWarning(const SQLWarning * _next) = 0; + +protected: + + virtual ~SQLWarning(){}; + + SQLWarning(const SQLWarning& e){}; + +private: + const SQLWarning & operator = (const SQLWarning & rhs); + +}; + + +} /* namespace sql */ + +#endif /* _SQL_WARNING_H_ */ diff --git a/sdk/include/mysql_connection.h b/sdk/include/mysql_connection.h new file mode 100644 index 0000000..23fc4c2 --- /dev/null +++ b/sdk/include/mysql_connection.h @@ -0,0 +1,178 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _MYSQL_CONNECTION_H_ +#define _MYSQL_CONNECTION_H_ + +#include +#include + +namespace sql +{ +namespace mysql +{ + +class MySQL_Savepoint : public sql::Savepoint +{ + sql::SQLString name; + +public: + MySQL_Savepoint(const sql::SQLString &savepoint); + virtual ~MySQL_Savepoint() {} + + int getSavepointId(); + + sql::SQLString getSavepointName(); + +private: + /* Prevent use of these */ + MySQL_Savepoint(const MySQL_Savepoint &); + void operator=(MySQL_Savepoint &); +}; + + +class MySQL_DebugLogger; +class MySQL_ConnectionData; /* PIMPL */ + +namespace NativeAPI +{ +class NativeConnectionWrapper; +} + +class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection +{ +public: + MySQL_Connection(Driver * _driver, + ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, + const sql::SQLString& hostName, + const sql::SQLString& userName, + const sql::SQLString& password); + + MySQL_Connection(Driver * _driver, ::sql::mysql::NativeAPI::NativeConnectionWrapper & _proxy, + std::map< sql::SQLString, sql::ConnectPropertyVal > & options); + + virtual ~MySQL_Connection(); + + void clearWarnings(); + + void close(); + + void commit(); + + sql::Statement * createStatement(); + + sql::SQLString escapeString(const sql::SQLString &); + + bool getAutoCommit(); + + sql::SQLString getCatalog(); + + Driver *getDriver(); + + sql::SQLString getSchema(); + + sql::SQLString getClientInfo(); + + void getClientOption(const sql::SQLString & optionName, void * optionValue); + + sql::DatabaseMetaData * getMetaData(); + + enum_transaction_isolation getTransactionIsolation(); + + const SQLWarning * getWarnings(); + + bool isClosed(); + + bool isReadOnly(); + + sql::SQLString nativeSQL(const sql::SQLString& sql); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability); + + sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]); + + void releaseSavepoint(Savepoint * savepoint) ; + + void rollback(); + + void rollback(Savepoint * savepoint); + + void setAutoCommit(bool autoCommit); + + void setCatalog(const sql::SQLString& catalog); + + void setSchema(const sql::SQLString& catalog); + + sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue); + + void setHoldability(int holdability); + + void setReadOnly(bool readOnly); + + sql::Savepoint * setSavepoint(); + + sql::Savepoint * setSavepoint(const sql::SQLString& name); + + void setTransactionIsolation(enum_transaction_isolation level); + + sql::SQLString getSessionVariable(const sql::SQLString & varname); + + void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value); + +protected: + void checkClosed(); + void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties); + + Driver * driver; + boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy; + + MySQL_ConnectionData * intern; /* pimpl */ + +private: + /* Prevent use of these */ + MySQL_Connection(const MySQL_Connection &); + void operator=(MySQL_Connection &); +}; + +} /* namespace mysql */ +} /* namespace sql */ + +#endif // _MYSQL_CONNECTION_H_ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/sdk/include/mysql_driver.h b/sdk/include/mysql_driver.h new file mode 100644 index 0000000..f2d4933 --- /dev/null +++ b/sdk/include/mysql_driver.h @@ -0,0 +1,102 @@ +/* + Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + + The MySQL Connector/C++ is licensed under the terms of the GPLv2 + , like most + MySQL Connectors. There are special exceptions to the terms and + conditions of the GPLv2 as it is applied to this software, see the + FLOSS License Exception + . + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + 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 +*/ + +#ifndef _MYSQL_DRIVER_H_ +#define _MYSQL_DRIVER_H_ + +#include + +#include + +extern "C" +{ +CPPCONN_PUBLIC_FUNC void * sql_mysql_get_driver_instance(); +} + +namespace sql +{ +namespace mysql +{ +namespace NativeAPI +{ + class NativeDriverWrapper; +} + +//class sql::mysql::NativeAPI::NativeDriverWrapper; + +class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver +{ + boost::scoped_ptr< ::sql::mysql::NativeAPI::NativeDriverWrapper > proxy; + +public: + MySQL_Driver(); + MySQL_Driver(const ::sql::SQLString & clientLib); + + virtual ~MySQL_Driver(); + + sql::Connection * connect(const sql::SQLString& hostName, const sql::SQLString& userName, const sql::SQLString& password); + + sql::Connection * connect(sql::ConnectOptionsMap & options); + + int getMajorVersion(); + + int getMinorVersion(); + + int getPatchVersion(); + + const sql::SQLString & getName(); + + void threadInit(); + + void threadEnd(); + +private: + /* Prevent use of these */ + MySQL_Driver(const MySQL_Driver &); + void operator=(MySQL_Driver &); +}; + +/** We do not hide the function if MYSQLCLIENT_STATIC_BINDING(or anything else) not defined + because the counterpart C function is declared in the cppconn and is always visible. + If dynamic loading is not enabled then its result is just like of get_driver_instance() +*/ +CPPCONN_PUBLIC_FUNC MySQL_Driver * get_driver_instance_by_name(const char * const clientlib); + +CPPCONN_PUBLIC_FUNC MySQL_Driver * get_driver_instance(); +static inline MySQL_Driver * get_mysql_driver_instance() { return get_driver_instance(); } + + +} /* namespace mysql */ +} /* namespace sql */ + +#endif // _MYSQL_DRIVER_H_ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/sdk/include/opdatabase.h b/sdk/include/opdatabase.h index faed5a7..edc5ce5 100644 --- a/sdk/include/opdatabase.h +++ b/sdk/include/opdatabase.h @@ -12,7 +12,7 @@ public: void CloseDatabase(); bool OpenDatabase(const std::string& db_file_path); void InsertMessage(const std::string& ts, const std::string& msg_type, const std::string& fsu, const std::string& content,int topic,int dev_id); - bool QueryUser(const std::string& uname, const std::string& passwd); + bool QueryUser(const std::string& uname, const std::string& passwd, std::string& resultJson); protected: sqlite3* m_pSqliteDb; private: