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

#include <SQLCore.h>

Inheritance diagram for SQL::Connection:
Object IBConnection IFXConnection MyConnection ODBCConnection OciConnection PeConnection PqConnection SqConnection

Public Types

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

Public Member Functions

long refCount () const
long addRef ()
long release ()
bool open (const char *_conn, size_t _connlen)
bool close ()
bool execute (const char *_sql, size_t _sqllen)
bool startTrans ()
bool commitTrans ()
bool rollbackTrans ()
bool getErrorMessage (char *_buf, size_t *_buflen)
bool getServerInfo (char *_buf, size_t *_buflen)
bool createQueryInstance (Query **_queryHandle)
bool destroyQueryInstance (Query *_queryHandle)
Error errorCode () const
bool canTransact () const
const wchar_t * serverTitle () const
bool inState (unsigned int _state) 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 splitConnStr (const char *_connstr, size_t _strlen, ListedByteStringToByteStringMap &_results)

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 *_conn, 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 **_queryHandle)=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 326 of file SQLCore.h.

Member Enumeration Documentation

◆ State

Enumerator
stClosed 
stOpenned 
stInTransaction 

Definition at line 428 of file SQLCore.h.

429 {
430 stClosed = 0x0001,
431 stOpenned = 0x0002,
432 stInTransaction = 0x0004
433 };

Constructor & Destructor Documentation

◆ Connection()

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

Definition at line 665 of file SQLCore.cpp.

668{
669 __refCount = 0;
670
671 __canTransact = false;
672 __serverTitle = _serverTitle;
673
676 __errorLine = 0;
677
679}
#define NULL
Definition Config.h:312
bool __canTransact
Definition SQLCore.h:418
const wchar_t * __serverTitle
Definition SQLCore.h:419
unsigned int __states
Definition SQLCore.h:426
Error __errorCode
Definition SQLCore.h:421
const wchar_t * __errorFileName
Definition SQLCore.h:422
@ eNoError
Definition SQLCore.h:20

◆ ~Connection()

SQL::Connection::~Connection ( )
protectedvirtual

Definition at line 681 of file SQLCore.cpp.

682{
683 __DCL_ASSERT(refCount() == 0);
684}
#define __DCL_ASSERT(expr)
Definition Object.h:394
long refCount() const
Definition SQLCore.h:333

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 ** _queryHandle)
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 * _conn,
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 705 of file SQLCore.cpp.

706{
707 if (!inState(stOpenned)) {
709 return false;
710 }
711
712 if (refCount()) {
714 return false;
715 }
716
717 if (__close()) {
719 return true;
720 }
721 return false;
722}
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:149
#define __SET_STATE(state)
Definition SQLCore.h:482
virtual bool __close()=0
bool inState(unsigned int _state) const
Definition SQLCore.inl:99
@ eNotConnected
Definition SQLCore.h:33
@ eHaveChildQuery
Definition SQLCore.h:36

◆ commitTrans()

bool SQL::Connection::commitTrans ( )

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 (__commitTrans()) {
772 return true;
773 }
774 return false;
775}
#define __UNSET_STATE(state)
Definition SQLCore.h:483
virtual bool __commitTrans()=0
@ eNotInTransaction
Definition SQLCore.h:35

◆ createQueryInstance()

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

Definition at line 823 of file SQLCore.cpp.

826{
827 if (!inState(stOpenned)) {
829 return false;
830 }
831
832 __CHECK_ADDRESS(_queryHandleOut);
833
834 if (__createQueryInstance(_queryHandleOut)) {
835 addRef();
836 return true;
837 }
838 return false;
839}
#define __CHECK_ADDRESS(p)
Definition SQLCore.cpp:139
virtual bool __createQueryInstance(Query **_queryHandle)=0

◆ destroy()

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

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

Reimplemented from Object.

Implemented in IBConnection, IFXConnection, MyConnection, OciConnection, ODBCConnection, PeConnection, PqConnection, and SqConnection.

◆ destroyQueryInstance()

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

Definition at line 841 of file SQLCore.cpp.

844{
845 if (!inState(stOpenned)) {
847 return false;
848 }
849
850 if (_queryHandle->__connHandle != this) {
852 return false;
853 }
854
855 release();
856 _queryHandle->__destroy();
857 return true;
858}
Connection * __connHandle
Definition SQLCore.h:302
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 724 of file SQLCore.cpp.

728{
729 if (!inState(stOpenned)) {
731 return false;
732 }
733
734 __CHECK_ADDRESS(_sql)
735
736 return __execute(_sql, _sqllen);
737}
virtual bool __execute(const char *_sql, size_t _sqllen)=0

◆ getErrorMessage()

bool SQL::Connection::getErrorMessage ( char * _buf,
size_t * _buflen )

Definition at line 796 of file SQLCore.cpp.

800{
801 if ((_buf == NULL) || (_buflen == NULL) || (*_buflen <= 0))
802 return false;
803
804 return __getErrorMessage(_buf, _buflen);
805}
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)=0

◆ getServerInfo()

bool SQL::Connection::getServerInfo ( char * _buf,
size_t * _buflen )

Definition at line 807 of file SQLCore.cpp.

811{
812 if (!inState(stOpenned)) {
814 return false;
815 }
816
817 __CHECK_ADDRESS(_buf)
818 __CHECK_ADDRESS(_buflen)
819
820 return __getServerInfo(_buf, _buflen);
821}
virtual bool __getServerInfo(char *_buf, size_t *_buflen)=0

◆ inState()

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

Definition at line 99 of file SQLCore.inl.

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

◆ open()

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

Definition at line 686 of file SQLCore.cpp.

690{
691 if (inState(stOpenned)) {
693 return false;
694 }
695
696 __CHECK_ADDRESS(_connString)
697
698 if (__open(_connString, _connlen)) {
700 return true;
701 }
702 return false;
703}
virtual bool __open(const char *_conn, size_t _connlen)=0
@ eConnected
Definition SQLCore.h:32

◆ refCount()

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

Definition at line 333 of file SQLCore.h.

333{ return __refCount; }

◆ release()

long SQL::Connection::release ( )

Definition at line 658 of file SQLCore.cpp.

659{
660 long n = Thread::decrementAndGet(__refCount);
661 __DCL_ASSERT(n >= 0);
662 return n;
663}
static long decrementAndGet(volatile long &_n)

◆ rollbackTrans()

bool SQL::Connection::rollbackTrans ( )

Definition at line 777 of file SQLCore.cpp.

778{
779 if (!inState(stOpenned)) {
781 return false;
782 }
783
784 if (!inState(stInTransaction)) {
786 return false;
787 }
788
789 if (__rollbackTrans()) {
791 return true;
792 }
793 return false;
794}
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}

◆ splitConnStr()

size_t SQL::Connection::splitConnStr ( const char * _connstr,
size_t _strlen,
ListedByteStringToByteStringMap & _results )
static

Definition at line 862 of file SQLCore.cpp.

867{
868 __DCL_ASSERT(_connstr != NULL);
869 ByteStringArray elts;
870 ByteString::split(
871 _connstr, _connstr + _strlen,
872 ';', elts
873 );
874
875 for(ByteStringArray::Iterator it = elts.begin();
876 it != elts.end(); it++) {
877 ByteStringArray pair;
878 (*it).split('=', pair);
879 if (pair.size() > 0) {
880 ByteStringArray::Iterator itPair = pair.begin();
881 ByteString name = *itPair++;
882 ByteString value;
883 if (pair.size() > 1) {
884 value = *itPair;
885 }
886 _results[name.trim().toUpperCase()] = value.trim();
887 }
888 }
889 return _results.size();
890}

◆ startTrans()

bool SQL::Connection::startTrans ( )

Definition at line 739 of file SQLCore.cpp.

740{
741 if (!inState(stOpenned)) {
743 return false;
744 }
745
748 return false;
749 }
750
751 if (__startTrans()) {
753 return true;
754 }
755 return false;
756}
virtual bool __startTrans()=0
@ eInTransaction
Definition SQLCore.h:34

Member Data Documentation

◆ __canTransact

bool SQL::Connection::__canTransact
protected

Definition at line 418 of file SQLCore.h.

◆ __errorCode

Error SQL::Connection::__errorCode
protected

Definition at line 421 of file SQLCore.h.

◆ __errorFileName

const wchar_t* SQL::Connection::__errorFileName
protected

Definition at line 422 of file SQLCore.h.

◆ __errorLine

int SQL::Connection::__errorLine
protected

Definition at line 423 of file SQLCore.h.

◆ __pad0__

_PROTECTED SQL::Connection::__pad0__

Definition at line 435 of file SQLCore.h.

◆ __serverTitle

const wchar_t* SQL::Connection::__serverTitle
protected

Definition at line 419 of file SQLCore.h.

◆ __states

unsigned int SQL::Connection::__states
protected

Definition at line 426 of file SQLCore.h.

◆ _filename

_PROTECTED const wchar_t* SQL::Connection::_filename

Definition at line 439 of file SQLCore.h.

◆ _line

_PROTECTED const wchar_t int SQL::Connection::_line

Definition at line 440 of file SQLCore.h.


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