DCL 4.0
Loading...
Searching...
No Matches
SQLConnection Class Reference

#include <SQL.h>

Inheritance diagram for SQLConnection:
Object

Public Member Functions

 SQLConnection (SQLDriver *_driver)
 SQLConnection (const String &_driverName) __DCL_THROWS1(SQLDriverException *)
virtual ~SQLConnection ()
void open (const String &_connString) __DCL_THROWS2(SQLException *
void CharsetConvertException *void close () __DCL_THROWS1(SQLException *)
void execute (const String &_sql) __DCL_THROWS2(SQLException *
void CharsetConvertException *void startTrans () __DCL_THROWS1(SQLException *)
void commitTrans () __DCL_THROWS1(SQLException *)
void rollbackTrans () __DCL_THROWS1(SQLException *)
String getServerInfo () __DCL_THROWS2(SQLException *
String CharsetConvertException *bool canTransact () const
SQL::Connectionhandle () const
SQLDriverdriver () const
bool connected () const
bool inTransaction () const
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Attributes

SQL::Connection__handle
SQLDriver__driver
bool __connected

Additional Inherited Members

Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Detailed Description

Definition at line 304 of file SQL.h.

Constructor & Destructor Documentation

◆ SQLConnection() [1/2]

SQLConnection::SQLConnection ( SQLDriver * _driver)

Definition at line 43 of file SQLConnection.cpp.

44{
45 __DCL_ASSERT_PARAM(_driver != NULL);
46 initialize(_driver);
47}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:384

◆ SQLConnection() [2/2]

SQLConnection::SQLConnection ( const String & _driverName)

Definition at line 49 of file SQLConnection.cpp.

51{
52 __DCL_ASSERT_PARAM(!_driverName.isEmpty());
53
54 SQLDriver* _driver = SQLDriver::getDriver(_driverName);
55 initialize(_driver);
56}
static SQLDriver * getDriver(const String &_name) __DCL_THROWS1(SQLDriverException *)

◆ ~SQLConnection()

SQLConnection::~SQLConnection ( )
virtual

Definition at line 58 of file SQLConnection.cpp.

59{
60 __DCL_ASSERT(__handle->refCount() == 0);
61 if (__connected) {
62 try {
63 //__DCL_TRACE0(__T("close()\n"));
64 close();
65 }
66 catch (SQLException* e) {
67 __DCL_TRACE1(__T("Warning! %ls\n"), e->toString().data());
68 e->destroy();
69 }
70 }
71
72 __driver->destroyConnection(__handle);
73 //__handle = NULL;
74 //__driver = NULL;
75}
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:376
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
virtual void destroy()
Definition Exception.cpp:74
SQLDriver * __driver
Definition SQL.h:340
bool __connected
Definition SQL.h:341
SQL::Connection * __handle
Definition SQL.h:339
void CharsetConvertException *void close() __DCL_THROWS1(SQLException *)
virtual String toString() const

Member Function Documentation

◆ canTransact()

bool SQLConnection::canTransact ( ) const

Definition at line 188 of file SQLConnection.cpp.

189{
192 return __handle->canTransact();
193}

◆ close()

void SQLConnection::close ( )

Definition at line 97 of file SQLConnection.cpp.

98{
100
101 if (__connected) {
102 if (inTransaction())
104
105 if (!__handle->close()) {
106 throw new SQLException(this);
107 }
108
109 __connected = false;
110 }
111}
void rollbackTrans() __DCL_THROWS1(SQLException *)
bool inTransaction() const

◆ commitTrans()

void SQLConnection::commitTrans ( )

Definition at line 137 of file SQLConnection.cpp.

138{
141// __DCL_ASSERT(inTransaction());
142
143 if (!__handle->commitTrans()) {
144 throw new SQLException(this);
145 }
146}

◆ connected()

bool SQLConnection::connected ( ) const
inline

Definition at line 170 of file SQL.inl.

171{
172 return __connected;
173}

◆ driver()

SQLDriver * SQLConnection::driver ( ) const
inline

Definition at line 165 of file SQL.inl.

166{
167 return __driver;
168}

◆ execute()

void SQLConnection::execute ( const String & _sql)

◆ getServerInfo()

String SQLConnection::getServerInfo ( )

◆ handle()

SQL::Connection * SQLConnection::handle ( ) const
inline

Definition at line 160 of file SQL.inl.

161{
162 return __handle;
163}

◆ inTransaction()

bool SQLConnection::inTransaction ( ) const

Definition at line 159 of file SQLConnection.cpp.

160{
162
163 if (__connected) {
165 }
166 return false;
167}

◆ open()

void SQLConnection::open ( const String & _connString)

◆ rollbackTrans()

void SQLConnection::rollbackTrans ( )

Definition at line 148 of file SQLConnection.cpp.

149{
152// __DCL_ASSERT(inTransaction());
153
154 if (!__handle->rollbackTrans()) {
155 throw new SQLException(this);
156 }
157}

◆ startTrans()

void SQLConnection::startTrans ( )

Definition at line 126 of file SQLConnection.cpp.

127{
130// __DCL_ASSERT(!inTransaction());
131
132 if (!__handle->startTrans()) {
133 throw new SQLException(this);
134 }
135}

Member Data Documentation

◆ __connected

bool SQLConnection::__connected
protected

Definition at line 341 of file SQL.h.

◆ __driver

SQLDriver* SQLConnection::__driver
protected

Definition at line 340 of file SQL.h.

◆ __handle

SQL::Connection* SQLConnection::__handle
protected

Definition at line 339 of file SQL.h.


The documentation for this class was generated from the following files: