DCL 4.1
Loading...
Searching...
No Matches
SQL::Connection Class Referenceabstract

#include <SQLCore.h>

Inheritance diagram for SQL::Connection:
Object IBConnection IFXConnection MyConnection OciConnection PgConnection

Public Types

enum  State { stClosed = 0x0001 , stOpenned = 0x0002 , stInTransaction = 0x0004 }

Public Member Functions

long refCount () const
long addRef ()
long release ()
bool open (const char *_connString, size_t _connlen)
bool close ()
bool execute (const char *_sql, size_t _sqllen)
bool startTrans ()
bool commitTrans ()
bool rollbackTrans ()
bool getErrorMessage (char *_pbuf, size_t *_pn)
bool getServerInfo (char *_pbuf, size_t *_pn)
bool createQueryInstance (Query **_queryHandleOut)
bool destroyQueryInstance (Query *_queryHandle)
Error errorCode () const
bool canTransact () const
const wchar_t * serverTitle () const
bool inState (unsigned int uState) const
virtual void destroy ()=0
Public Member Functions inherited from Object
virtual String toString () const
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Static Public Member Functions

static size_t splitConnectionString (const char *_connString, size_t _strlen, ListedByteStringToByteStringMap &_map)

Public Attributes

__PROTECTED : void setErrorStatus(Error _errorCode
__PROTECTED const wchar_t * _filename
__PROTECTED const wchar_t int _line

Protected Member Functions

 Connection (const wchar_t *_serverTitle)
virtual ~Connection ()
virtual bool __open (const char *_connString, size_t _connlen)=0
virtual bool __close ()=0
virtual bool __execute (const char *_sql, size_t _sqllen)=0
virtual bool __startTrans ()=0
virtual bool __commitTrans ()=0
virtual bool __rollbackTrans ()=0
virtual bool __createQueryInstance (Query **_queryHandleOut)=0
virtual bool __getErrorMessage (char *_buf, size_t *_buflen)=0
virtual bool __getServerInfo (char *_buf, size_t *_buflen)=0
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Protected Attributes

bool __canTransact
const wchar_t * __serverTitle
Error __errorCode
const wchar_t * __errorFileName
int __errorLine
unsigned int __states

Detailed Description

Definition at line 311 of file SQLCore.h.

Member Enumeration Documentation

◆ State

Enumerator
stClosed 
stOpenned 
stInTransaction 

Definition at line 383 of file SQLCore.h.

384 {
385 stClosed = 0x0001,
386 stOpenned = 0x0002,
387 stInTransaction = 0x0004
388 };

Constructor & Destructor Documentation

◆ Connection()

SQL::Connection::Connection ( const wchar_t * _serverTitle)
protected

Definition at line 646 of file SQLCore.cpp.

649{
650 __refCount = 0;
651
652 __canTransact = false;
653 __serverTitle = _serverTitle;
654
657 __errorLine = 0;
658
660}
#define NULL
Definition Config.h:340
bool __canTransact
Definition SQLCore.h:373
const wchar_t * __serverTitle
Definition SQLCore.h:374
unsigned int __states
Definition SQLCore.h:381
Error __errorCode
Definition SQLCore.h:376
const wchar_t * __errorFileName
Definition SQLCore.h:377
@ eNoError
Definition SQLCore.h:20

◆ ~Connection()

SQL::Connection::~Connection ( )
protectedvirtual

Definition at line 662 of file SQLCore.cpp.

663{
664 __DCL_ASSERT(refCount() == 0);
665}
#define __DCL_ASSERT(expr)
Definition Object.h:371
long refCount() const
Definition SQLCore.h:318

Member Function Documentation

◆ __close()

virtual bool SQL::Connection::__close ( )
protectedpure virtual

◆ __commitTrans()

virtual bool SQL::Connection::__commitTrans ( )
protectedpure virtual

◆ __createQueryInstance()

virtual bool SQL::Connection::__createQueryInstance ( Query ** _queryHandleOut)
protectedpure virtual

◆ __execute()

virtual bool SQL::Connection::__execute ( const char * _sql,
size_t _sqllen )
protectedpure virtual

◆ __getErrorMessage()

virtual bool SQL::Connection::__getErrorMessage ( char * _buf,
size_t * _buflen )
protectedpure virtual

◆ __getServerInfo()

virtual bool SQL::Connection::__getServerInfo ( char * _buf,
size_t * _buflen )
protectedpure virtual

◆ __open()

virtual bool SQL::Connection::__open ( const char * _connString,
size_t _connlen )
protectedpure virtual

◆ __rollbackTrans()

virtual bool SQL::Connection::__rollbackTrans ( )
protectedpure virtual

◆ __startTrans()

virtual bool SQL::Connection::__startTrans ( )
protectedpure virtual

◆ addRef()

long SQL::Connection::addRef ( )

◆ canTransact()

bool SQL::Connection::canTransact ( ) const
inline

Definition at line 89 of file SQLCore.inl.

90{
91 return __canTransact;
92}

◆ close()

bool SQL::Connection::close ( )

Definition at line 686 of file SQLCore.cpp.

687{
688 if (!inState(stOpenned)) {
690 return false;
691 }
692
693 if (refCount()) {
695 return false;
696 }
697
698 if (__close()) {
700 return true;
701 }
702 return false;
703}
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:153
#define __SET_STATE(state)
Definition SQLCore.h:432
bool inState(unsigned int uState) const
Definition SQLCore.inl:99
virtual bool __close()=0
@ eNotConnected
Definition SQLCore.h:33
@ eHaveChildQuery
Definition SQLCore.h:36

◆ commitTrans()

bool SQL::Connection::commitTrans ( )

Definition at line 739 of file SQLCore.cpp.

740{
741 if (!inState(stOpenned)) {
743 return false;
744 }
745
746 if (!inState(stInTransaction)) {
748 return false;
749 }
750
751 if (__commitTrans()) {
753 return true;
754 }
755 return false;
756}
#define __UNSET_STATE(state)
Definition SQLCore.h:433
virtual bool __commitTrans()=0
@ eNotInTransaction
Definition SQLCore.h:35

◆ createQueryInstance()

bool SQL::Connection::createQueryInstance ( SQL::Query ** _queryHandleOut)

Definition at line 804 of file SQLCore.cpp.

807{
808 if (!inState(stOpenned)) {
810 return false;
811 }
812
813 __CHECK_ADDRESS(_queryHandleOut);
814
815 if (__createQueryInstance(_queryHandleOut)) {
816 addRef();
817 return true;
818 }
819 return false;
820}
#define __CHECK_ADDRESS(p)
Definition SQLCore.cpp:142
virtual bool __createQueryInstance(Query **_queryHandleOut)=0

◆ destroy()

virtual void SQL::Connection::destroy ( )
pure virtual

파생클래스에서 new 연산자를 override했거나, 추가적인 행위가 필요하다면 이것도 override하라

Reimplemented from Object.

Implemented in IBConnection, IFXConnection, MyConnection, OciConnection, and PgConnection.

◆ destroyQueryInstance()

bool SQL::Connection::destroyQueryInstance ( SQL::Query * _queryHandle)

Definition at line 822 of file SQLCore.cpp.

825{
826 if (!inState(stOpenned)) {
828 return false;
829 }
830
831 if (_queryHandle->__connHandle != this) {
833 return false;
834 }
835
836 release();
837 _queryHandle->__destroy();
838 return true;
839}
Connection * __connHandle
Definition SQLCore.h:287
virtual void __destroy()=0
@ eNoChildQuery
Definition SQLCore.h:37

◆ errorCode()

SQL::Error SQL::Connection::errorCode ( ) const
inline

Definition at line 72 of file SQLCore.inl.

73{
74 return __errorCode;
75}

◆ execute()

bool SQL::Connection::execute ( const char * _sql,
size_t _sqllen )

Definition at line 705 of file SQLCore.cpp.

709{
710 if (!inState(stOpenned)) {
712 return false;
713 }
714
715 __CHECK_ADDRESS(_sql)
716
717 return __execute(_sql, _sqllen);
718}
virtual bool __execute(const char *_sql, size_t _sqllen)=0

◆ getErrorMessage()

bool SQL::Connection::getErrorMessage ( char * _pbuf,
size_t * _pn )

Definition at line 777 of file SQLCore.cpp.

781{
782 if ((_buf == NULL) || (_buflen == NULL) || (*_buflen <= 0))
783 return false;
784
785 return __getErrorMessage(_buf, _buflen);
786}
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)=0

◆ getServerInfo()

bool SQL::Connection::getServerInfo ( char * _pbuf,
size_t * _pn )

Definition at line 788 of file SQLCore.cpp.

792{
793 if (!inState(stOpenned)) {
795 return false;
796 }
797
798 __CHECK_ADDRESS(_buf)
799 __CHECK_ADDRESS(_buflen)
800
801 return __getServerInfo(_buf, _buflen);
802}
virtual bool __getServerInfo(char *_buf, size_t *_buflen)=0

◆ inState()

bool SQL::Connection::inState ( unsigned int uState) const
inline

Definition at line 99 of file SQLCore.inl.

100{
101 return (__states & _state) == _state;
102}

◆ open()

bool SQL::Connection::open ( const char * _connString,
size_t _connlen )

Definition at line 667 of file SQLCore.cpp.

671{
672 if (inState(stOpenned)) {
674 return false;
675 }
676
677 __CHECK_ADDRESS(_connString)
678
679 if (__open(_connString, _connlen)) {
681 return true;
682 }
683 return false;
684}
virtual bool __open(const char *_connString, size_t _connlen)=0
@ eConnected
Definition SQLCore.h:32

◆ refCount()

long SQL::Connection::refCount ( ) const
inline

Definition at line 318 of file SQLCore.h.

318{ return __refCount; }

◆ release()

long SQL::Connection::release ( )

Definition at line 639 of file SQLCore.cpp.

640{
641 long n = Thread::decrementAndGet(__refCount);
642 __DCL_ASSERT(n >= 0);
643 return n;
644}
void CharsetConvertException *size_t n
Definition SQLField.cpp:254
static long decrementAndGet(volatile long &_n)

◆ rollbackTrans()

bool SQL::Connection::rollbackTrans ( )

Definition at line 758 of file SQLCore.cpp.

759{
760 if (!inState(stOpenned)) {
762 return false;
763 }
764
765 if (!inState(stInTransaction)) {
767 return false;
768 }
769
770 if (__rollbackTrans()) {
772 return true;
773 }
774 return false;
775}
virtual bool __rollbackTrans()=0

◆ serverTitle()

const wchar_t * SQL::Connection::serverTitle ( ) const
inline

Definition at line 94 of file SQLCore.inl.

95{
96 return __serverTitle;
97}

◆ splitConnectionString()

size_t SQL::Connection::splitConnectionString ( const char * _connString,
size_t _strlen,
ListedByteStringToByteStringMap & _map )
static

Definition at line 843 of file SQLCore.cpp.

848{
849 __DCL_ASSERT(_pszConnectionString != NULL);
850 ByteStringArray elts;
851 ByteString::split(
852 _pszConnectionString, _pszConnectionString + _n,
853 ';', elts
854 );
855
856 for(ByteStringArray::Iterator it = elts.begin();
857 it != elts.end(); it++) {
858 ByteStringArray pair;
859 (*it).split('=', pair);
860 if (pair.size() > 0) {
861 ByteStringArray::Iterator itPair = pair.begin();
862 ByteString name = *itPair++;
863 ByteString value;
864 if (pair.size() > 1) {
865 value = *itPair;
866 }
867 _map[name.trim().toUpperCase()] = value.trim();
868 }
869 }
870 return _map.size();
871}

◆ startTrans()

bool SQL::Connection::startTrans ( )

Definition at line 720 of file SQLCore.cpp.

721{
722 if (!inState(stOpenned)) {
724 return false;
725 }
726
729 return false;
730 }
731
732 if (__startTrans()) {
734 return true;
735 }
736 return false;
737}
virtual bool __startTrans()=0
@ eInTransaction
Definition SQLCore.h:34

Member Data Documentation

◆ __canTransact

bool SQL::Connection::__canTransact
protected

Definition at line 373 of file SQLCore.h.

◆ __errorCode

Error SQL::Connection::__errorCode
protected

Definition at line 376 of file SQLCore.h.

◆ __errorFileName

const wchar_t* SQL::Connection::__errorFileName
protected

Definition at line 377 of file SQLCore.h.

◆ __errorLine

int SQL::Connection::__errorLine
protected

Definition at line 378 of file SQLCore.h.

◆ __pad0__

__PROTECTED SQL::Connection::__pad0__

Definition at line 390 of file SQLCore.h.

◆ __serverTitle

const wchar_t* SQL::Connection::__serverTitle
protected

Definition at line 374 of file SQLCore.h.

◆ __states

unsigned int SQL::Connection::__states
protected

Definition at line 381 of file SQLCore.h.

◆ _filename

__PROTECTED const wchar_t* SQL::Connection::_filename

Definition at line 392 of file SQLCore.h.

◆ _line

__PROTECTED const wchar_t int SQL::Connection::_line

Definition at line 392 of file SQLCore.h.


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