2024-05-29 09:27:48 +08:00
|
|
|
/*
|
2024-09-05 16:38:14 +08:00
|
|
|
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License, version 2.0, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is also distributed with certain software (including
|
|
|
|
* but not limited to OpenSSL) that is licensed under separate terms,
|
|
|
|
* as designated in a particular file or component or in included license
|
|
|
|
* documentation. The authors of MySQL hereby grant you an
|
|
|
|
* additional permission to link the program and your derivative works
|
|
|
|
* with the separately licensed software that they have included with
|
|
|
|
* MySQL.
|
|
|
|
*
|
|
|
|
* Without limiting anything contained in the foregoing, this file,
|
|
|
|
* which is part of MySQL Connector/C++, is also subject to the
|
|
|
|
* Universal FOSS Exception, version 1.0, a copy of which can be found at
|
|
|
|
* http://oss.oracle.com/licenses/universal-foss-exception.
|
|
|
|
*
|
|
|
|
* 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, version 2.0, 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
|
|
|
|
*/
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _MYSQL_CONNECTION_H_
|
|
|
|
#define _MYSQL_CONNECTION_H_
|
|
|
|
|
|
|
|
#include <cppconn/connection.h>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2024-09-05 16:38:14 +08:00
|
|
|
#include <boost/scoped_ptr.hpp>
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
namespace sql
|
|
|
|
{
|
|
|
|
namespace mysql
|
|
|
|
{
|
|
|
|
|
|
|
|
class MySQL_Savepoint : public sql::Savepoint
|
|
|
|
{
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString name;
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
public:
|
2024-09-05 16:38:14 +08:00
|
|
|
MySQL_Savepoint(const sql::SQLString &savepoint);
|
|
|
|
virtual ~MySQL_Savepoint() {}
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
int getSavepointId();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString getSavepointName();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
private:
|
2024-09-05 16:38:14 +08:00
|
|
|
/* Prevent use of these */
|
|
|
|
MySQL_Savepoint(const MySQL_Savepoint &);
|
|
|
|
void operator=(MySQL_Savepoint &);
|
2024-05-29 09:27:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class MySQL_DebugLogger;
|
2024-09-05 16:38:14 +08:00
|
|
|
struct MySQL_ConnectionData; /* PIMPL */
|
|
|
|
class MySQL_Statement;
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
namespace NativeAPI
|
|
|
|
{
|
|
|
|
class NativeConnectionWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
|
|
|
|
{
|
2024-09-05 16:38:14 +08:00
|
|
|
MySQL_Statement * createServiceStmt();
|
|
|
|
|
2024-05-29 09:27:48 +08:00
|
|
|
public:
|
2024-09-05 16:38:14 +08:00
|
|
|
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();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void clearWarnings();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void close();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void commit();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::Statement * createStatement();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString escapeString(const sql::SQLString &);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
bool getAutoCommit();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString getCatalog();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
Driver *getDriver();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString getSchema();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString getClientInfo();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void getClientOption(const sql::SQLString & optionName, void * optionValue);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString getClientOption(const sql::SQLString & optionName);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::DatabaseMetaData * getMetaData();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
enum_transaction_isolation getTransactionIsolation();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
const SQLWarning * getWarnings();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
bool isClosed();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
bool isReadOnly();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
bool isValid();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
bool reconnect();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::SQLString nativeSQL(const sql::SQLString& sql);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int columnIndexes[]);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void releaseSavepoint(Savepoint * savepoint) ;
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void rollback();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void rollback(Savepoint * savepoint);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setAutoCommit(bool autoCommit);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setCatalog(const sql::SQLString& catalog);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setSchema(const sql::SQLString& catalog);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setHoldability(int holdability);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setReadOnly(bool readOnly);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::Savepoint * setSavepoint();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
sql::Savepoint * setSavepoint(const sql::SQLString& name);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
void setTransactionIsolation(enum_transaction_isolation level);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
virtual sql::SQLString getSessionVariable(const sql::SQLString & varname);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
virtual void setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value);
|
2024-05-29 09:27:48 +08:00
|
|
|
|
2024-09-05 16:38:14 +08:00
|
|
|
virtual void setSessionVariable(const sql::SQLString & varname, unsigned int value);
|
|
|
|
|
|
|
|
virtual sql::SQLString getLastStatementInfo();
|
2024-05-29 09:27:48 +08:00
|
|
|
|
|
|
|
private:
|
2024-09-05 16:38:14 +08:00
|
|
|
/* We do not really think this class has to be subclassed*/
|
|
|
|
void checkClosed();
|
|
|
|
void init(std::map< sql::SQLString, sql::ConnectPropertyVal > & properties);
|
|
|
|
|
|
|
|
Driver * driver;
|
|
|
|
boost::shared_ptr< NativeAPI::NativeConnectionWrapper > proxy;
|
|
|
|
|
|
|
|
/* statement handle to execute queries initiated by driver. Perhaps it is
|
|
|
|
a good idea to move it to a separate helper class */
|
|
|
|
boost::scoped_ptr< ::sql::mysql::MySQL_Statement > service;
|
|
|
|
|
|
|
|
boost::scoped_ptr< ::sql::mysql::MySQL_ConnectionData > intern; /* pimpl */
|
|
|
|
|
|
|
|
/* Prevent use of these */
|
|
|
|
MySQL_Connection(const MySQL_Connection &);
|
|
|
|
void operator=(MySQL_Connection &);
|
2024-05-29 09:27:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* 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
|
|
|
|
*/
|