connection.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2.0, as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is also distributed with certain software (including
  9. * but not limited to OpenSSL) that is licensed under separate terms,
  10. * as designated in a particular file or component or in included license
  11. * documentation. The authors of MySQL hereby grant you an
  12. * additional permission to link the program and your derivative works
  13. * with the separately licensed software that they have included with
  14. * MySQL.
  15. *
  16. * Without limiting anything contained in the foregoing, this file,
  17. * which is part of MySQL Connector/C++, is also subject to the
  18. * Universal FOSS Exception, version 1.0, a copy of which can be found at
  19. * http://oss.oracle.com/licenses/universal-foss-exception.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. * See the GNU General Public License, version 2.0, for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #ifndef _SQL_CONNECTION_H_
  31. #define _SQL_CONNECTION_H_
  32. #include <map>
  33. #include "build_config.h"
  34. #include "warning.h"
  35. #include "sqlstring.h"
  36. #include "variant.h"
  37. namespace sql
  38. {
  39. typedef sql::Variant ConnectPropertyVal;
  40. typedef std::map< sql::SQLString, ConnectPropertyVal > ConnectOptionsMap;
  41. class DatabaseMetaData;
  42. class PreparedStatement;
  43. class Statement;
  44. class Driver;
  45. typedef enum transaction_isolation
  46. {
  47. TRANSACTION_NONE= 0,
  48. TRANSACTION_READ_COMMITTED,
  49. TRANSACTION_READ_UNCOMMITTED,
  50. TRANSACTION_REPEATABLE_READ,
  51. TRANSACTION_SERIALIZABLE
  52. } enum_transaction_isolation;
  53. enum ssl_mode
  54. {
  55. SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED,
  56. SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY
  57. };
  58. class Savepoint
  59. {
  60. /* Prevent use of these */
  61. Savepoint(const Savepoint &);
  62. void operator=(Savepoint &);
  63. public:
  64. Savepoint() {};
  65. virtual ~Savepoint() {};
  66. virtual int getSavepointId() = 0;
  67. virtual sql::SQLString getSavepointName() = 0;
  68. };
  69. class CPPCONN_PUBLIC_FUNC Connection
  70. {
  71. /* Prevent use of these */
  72. Connection(const Connection &);
  73. void operator=(Connection &);
  74. public:
  75. Connection() {};
  76. virtual ~Connection() {};
  77. virtual void clearWarnings() = 0;
  78. virtual Statement *createStatement() = 0;
  79. virtual void close() = 0;
  80. virtual void commit() = 0;
  81. virtual bool getAutoCommit() = 0;
  82. virtual sql::SQLString getCatalog() = 0;
  83. virtual Driver *getDriver() = 0;
  84. virtual sql::SQLString getSchema() = 0;
  85. virtual sql::SQLString getClientInfo() = 0;
  86. virtual void getClientOption(const sql::SQLString & optionName, void * optionValue) = 0;
  87. virtual sql::SQLString getClientOption(const sql::SQLString & optionName) = 0;
  88. virtual DatabaseMetaData * getMetaData() = 0;
  89. virtual enum_transaction_isolation getTransactionIsolation() = 0;
  90. virtual const SQLWarning * getWarnings() = 0;
  91. virtual bool isClosed() = 0;
  92. virtual bool isReadOnly() = 0;
  93. virtual bool isValid() = 0;
  94. virtual bool reconnect() = 0;
  95. virtual sql::SQLString nativeSQL(const sql::SQLString& sql) = 0;
  96. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql) = 0;
  97. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int autoGeneratedKeys) = 0;
  98. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int* columnIndexes) = 0;
  99. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency) = 0;
  100. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) = 0;
  101. virtual PreparedStatement * prepareStatement(const sql::SQLString& sql, sql::SQLString columnNames[]) = 0;
  102. virtual void releaseSavepoint(Savepoint * savepoint) = 0;
  103. virtual void rollback() = 0;
  104. virtual void rollback(Savepoint * savepoint) = 0;
  105. virtual void setAutoCommit(bool autoCommit) = 0;
  106. virtual void setCatalog(const sql::SQLString& catalog) = 0;
  107. virtual void setSchema(const sql::SQLString& catalog) = 0;
  108. virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const void * optionValue) = 0;
  109. virtual sql::Connection * setClientOption(const sql::SQLString & optionName, const sql::SQLString & optionValue) = 0;
  110. virtual void setHoldability(int holdability) = 0;
  111. virtual void setReadOnly(bool readOnly) = 0;
  112. virtual Savepoint * setSavepoint() = 0;
  113. virtual Savepoint * setSavepoint(const sql::SQLString& name) = 0;
  114. virtual void setTransactionIsolation(enum_transaction_isolation level) = 0;
  115. /* virtual void setTypeMap(Map map) = 0; */
  116. };
  117. } /* namespace sql */
  118. #endif // _SQL_CONNECTION_H_