|
| 1 | +/* |
| 2 | +Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
| 3 | +
|
| 4 | +The MySQL Connector/C++ is licensed under the terms of the GPLv2 |
| 5 | +<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most |
| 6 | +MySQL Connectors. There are special exceptions to the terms and |
| 7 | +conditions of the GPLv2 as it is applied to this software, see the |
| 8 | +FLOSS License Exception |
| 9 | +<http://www.mysql.com/about/legal/licensing/foss-exception.html>. |
| 10 | +
|
| 11 | +This program is free software; you can redistribute it and/or modify |
| 12 | +it under the terms of the GNU General Public License as published |
| 13 | +by the Free Software Foundation; version 2 of the License. |
| 14 | +
|
| 15 | +This program is distributed in the hope that it will be useful, but |
| 16 | +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 17 | +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 18 | +for more details. |
| 19 | +
|
| 20 | +You should have received a copy of the GNU General Public License along |
| 21 | +with this program; if not, write to the Free Software Foundation, Inc., |
| 22 | +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 23 | +*/ |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +#ifndef _SQL_CONNECTION_H_ |
| 28 | +#define _SQL_CONNECTION_H_ |
| 29 | + |
| 30 | +#include <map> |
| 31 | + |
| 32 | +#include "build_config.h" |
| 33 | +#include "warning.h" |
| 34 | +#include "sqlstring.h" |
| 35 | +#include "variant.h" |
| 36 | + |
| 37 | +namespace sql |
| 38 | +{ |
| 39 | + |
| 40 | +typedef sql::Variant ConnectPropertyVal; |
| 41 | + |
| 42 | +typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap; |
| 43 | + |
| 44 | +class DatabaseMetaData; |
| 45 | +class PreparedStatement; |
| 46 | +class Statement; |
| 47 | +class Driver; |
| 48 | + |
| 49 | +typedef enum transaction_isolation |
| 50 | +{ |
| 51 | + TRANSACTION_NONE= 0, |
| 52 | + TRANSACTION_READ_COMMITTED, |
| 53 | + TRANSACTION_READ_UNCOMMITTED, |
| 54 | + TRANSACTION_REPEATABLE_READ, |
| 55 | + TRANSACTION_SERIALIZABLE |
| 56 | +} enum_transaction_isolation; |
| 57 | + |
| 58 | +enum ssl_mode |
| 59 | +{ |
| 60 | + SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED, |
| 61 | + SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY |
| 62 | +}; |
| 63 | + |
| 64 | +class Savepoint |
| 65 | +{ |
| 66 | + /* Prevent use of these */ |
| 67 | + Savepoint(const Savepoint &); |
| 68 | + void operator=(Savepoint &); |
| 69 | +public: |
| 70 | + Savepoint() {}; |
| 71 | + virtual ~Savepoint() {}; |
| 72 | + virtual int getSavepointId() = 0; |
| 73 | + |
| 74 | + virtual sql::SQLString getSavepointName() = 0; |
| 75 | +}; |
| 76 | + |
| 77 | + |
| 78 | +class CPPCONN_PUBLIC_FUNC Connection |
| 79 | +{ |
| 80 | + /* Prevent use of these */ |
| 81 | + Connection(const Connection &); |
| 82 | + void operator=(Connection &); |
| 83 | +public: |
| 84 | + |
| 85 | + Connection() {}; |
| 86 | + |
| 87 | + virtual ~Connection() {}; |
| 88 | + |
| 89 | + virtual void clearWarnings() = 0; |
| 90 | + |
| 91 | + virtual Statement *createStatement() = 0; |
| 92 | + |
| 93 | + virtual void close() = 0; |
| 94 | + |
| 95 | + virtual void commit() = 0; |
| 96 | + |
| 97 | + virtual bool getAutoCommit() = 0; |
| 98 | + |
| 99 | + virtual sql::SQLString getCatalog() = 0; |
| 100 | + |
| 101 | + virtual Driver *getDriver() = 0; |
| 102 | + |
| 103 | + virtual sql::SQLString getSchema() = 0; |
| 104 | + |
| 105 | + virtual sql::SQLString getClientInfo() = 0; |
| 106 | + |
| 107 | + virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0; |
| 108 | + |
| 109 | + virtual sql::SQLString getClientOption(const sql::SQLString & optionName) = 0; |
| 110 | + |
| 111 | + virtual DatabaseMetaData * getMetaData() = 0; |
| 112 | + |
| 113 | + virtual enum_transaction_isolation getTransactionIsolation() = 0; |
| 114 | + |
| 115 | + virtual const SQLWarning * getWarnings() = 0; |
| 116 | + |
| 117 | + virtual bool isClosed() = 0; |
| 118 | + |
| 119 | + virtual bool isReadOnly() = 0; |
| 120 | + |
| 121 | + virtual bool isValid() = 0; |
| 122 | + |
| 123 | + virtual bool reconnect() = 0; |
| 124 | + |
| 125 | + virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0; |
| 126 | + |
| 127 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0; |
| 128 | + |
| 129 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0; |
| 130 | + |
| 131 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0; |
| 132 | + |
| 133 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0; |
| 134 | + |
| 135 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0; |
| 136 | + |
| 137 | + virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0; |
| 138 | + |
| 139 | + virtual void releaseSavepoint(Savepoint * savepoint) = 0; |
| 140 | + |
| 141 | + virtual void rollback() = 0; |
| 142 | + |
| 143 | + virtual void rollback(Savepoint * savepoint) = 0; |
| 144 | + |
| 145 | + virtual void setAutoCommit(bool autoCommit) = 0; |
| 146 | + |
| 147 | + virtual void setCatalog(const sql::SQLString& catalog) = 0; |
| 148 | + |
| 149 | + virtual void setSchema(const sql::SQLString& catalog) = 0; |
| 150 | + |
| 151 | + virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0; |
| 152 | + |
| 153 | + virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue) = 0; |
| 154 | + |
| 155 | + virtual void setHoldability(int holdability) = 0; |
| 156 | + |
| 157 | + virtual void setReadOnly(bool readOnly) = 0; |
| 158 | + |
| 159 | + virtual Savepoint * setSavepoint() = 0; |
| 160 | + |
| 161 | + virtual Savepoint * setSavepoint(const sql::SQLString& name) = 0; |
| 162 | + |
| 163 | + virtual void setTransactionIsolation(enum_transaction_isolation level) = 0; |
| 164 | + |
| 165 | + /* virtual void setTypeMap(Map map) = 0; */ |
| 166 | +}; |
| 167 | + |
| 168 | +} /* namespace sql */ |
| 169 | + |
| 170 | +#endif // _SQL_CONNECTION_H_ |
0 commit comments