DCL 4.0
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 309 of file SQLCore.h.

Member Enumeration Documentation

◆ State

Enumerator
stClosed 
stOpenned 
stInTransaction 

Definition at line 381 of file SQLCore.h.

382 {
383 stClosed = 0x0001,
384 stOpenned = 0x0002,
385 stInTransaction = 0x0004
386 };

Constructor & Destructor Documentation

◆ Connection()

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

Definition at line 653 of file SQLCore.cpp.

654{
655 __refCount = 0;
656
657 __canTransact = false;
658 __serverTitle = _serverTitle;
659
662 __errorLine = 0;
663
665}
#define NULL
Definition Config.h:340
bool __canTransact
Definition SQLCore.h:371
const wchar_t * __serverTitle
Definition SQLCore.h:372
unsigned int __states
Definition SQLCore.h:379
Error __errorCode
Definition SQLCore.h:374
const wchar_t * __errorFileName
Definition SQLCore.h:375
@ eNoError
Definition SQLCore.h:20

◆ ~Connection()

SQL::Connection::~Connection ( )
protectedvirtual

Definition at line 667 of file SQLCore.cpp.

668{
669 __DCL_ASSERT(refCount() == 0);
670}
#define __DCL_ASSERT(expr)
Definition Object.h:371
long refCount() const
Definition SQLCore.h:316

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 688 of file SQLCore.cpp.

689{
690 if (!inState(stOpenned)) {
692 return false;
693 }
694
695 if (refCount()) {
697 return false;
698 }
699
700 if (__close()) {
702 return true;
703 }
704 return false;
705}
#define __SET_ERROR(_errorCode)
Definition SQLCore.cpp:150
#define __SET_STATE(state)
Definition SQLCore.h:430
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 738 of file SQLCore.cpp.

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

◆ createQueryInstance()

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

Definition at line 797 of file SQLCore.cpp.

798{
799 if (!inState(stOpenned)) {
801 return false;
802 }
803
804 __CHECK_ADDRESS(_queryHandleOut);
805
806 if (__createQueryInstance(_queryHandleOut)) {
807 addRef();
808 return true;
809 }
810 return false;
811}
#define __CHECK_ADDRESS(p)
Definition SQLCore.cpp:139
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 813 of file SQLCore.cpp.

814{
815 if (!inState(stOpenned)) {
817 return false;
818 }
819
820 if (_queryHandle->__connHandle != this) {
822 return false;
823 }
824
825 release();
826 _queryHandle->__destroy();
827 return true;
828}
Connection * __connHandle
Definition SQLCore.h:285
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 707 of file SQLCore.cpp.

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

◆ getErrorMessage()

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

Definition at line 776 of file SQLCore.cpp.

777{
778 if ((_buf == NULL) || (_buflen == NULL) || (*_buflen <= 0))
779 return false;
780
781 return __getErrorMessage(_buf, _buflen);
782}
virtual bool __getErrorMessage(char *_buf, size_t *_buflen)=0

◆ getServerInfo()

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

Definition at line 784 of file SQLCore.cpp.

785{
786 if (!inState(stOpenned)) {
788 return false;
789 }
790
791 __CHECK_ADDRESS(_buf)
792 __CHECK_ADDRESS(_buflen)
793
794 return __getServerInfo(_buf, _buflen);
795}
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 672 of file SQLCore.cpp.

673{
674 if (inState(stOpenned)) {
676 return false;
677 }
678
679 __CHECK_ADDRESS(_connString)
680
681 if (__open(_connString, _connlen)) {
683 return true;
684 }
685 return false;
686}
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 316 of file SQLCore.h.

316{ return __refCount; }

◆ release()

long SQL::Connection::release ( )

Definition at line 646 of file SQLCore.cpp.

647{
648 long n = Thread::decrementAndGet(__refCount);
649 __DCL_ASSERT(n >= 0);
650 return n;
651}
void CharsetConvertException *size_t n
Definition SQLField.cpp:253
static long decrementAndGet(volatile long &_n)

◆ rollbackTrans()

bool SQL::Connection::rollbackTrans ( )

Definition at line 757 of file SQLCore.cpp.

758{
759 if (!inState(stOpenned)) {
761 return false;
762 }
763
764 if (!inState(stInTransaction)) {
766 return false;
767 }
768
769 if (__rollbackTrans()) {
771 return true;
772 }
773 return false;
774}
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 832 of file SQLCore.cpp.

836{
837 __DCL_ASSERT(_pszConnectionString != NULL);
838 ByteStringArray elts;
839 ByteString::split(
840 _pszConnectionString, _pszConnectionString + _n,
841 ';', elts
842 );
843
844 for(ByteStringArray::Iterator it = elts.begin(); it != elts.end(); it++) {
845 ByteStringArray pair;
846 (*it).split('=', pair);
847 if (pair.size() > 0) {
848 ByteStringArray::Iterator itPair = pair.begin();
849 ByteString name = *itPair++;
850 ByteString value;
851 if (pair.size() > 1) {
852 value = *itPair;
853 }
854 _map[name.trim().toUpperCase()] = value.trim();
855 }
856 }
857 return _map.size();
858}

◆ startTrans()

bool SQL::Connection::startTrans ( )

Definition at line 719 of file SQLCore.cpp.

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

Member Data Documentation

◆ __canTransact

bool SQL::Connection::__canTransact
protected

Definition at line 371 of file SQLCore.h.

◆ __errorCode

Error SQL::Connection::__errorCode
protected

Definition at line 374 of file SQLCore.h.

◆ __errorFileName

const wchar_t* SQL::Connection::__errorFileName
protected

Definition at line 375 of file SQLCore.h.

◆ __errorLine

int SQL::Connection::__errorLine
protected

Definition at line 376 of file SQLCore.h.

◆ __pad0__

__PROTECTED SQL::Connection::__pad0__

Definition at line 388 of file SQLCore.h.

◆ __serverTitle

const wchar_t* SQL::Connection::__serverTitle
protected

Definition at line 372 of file SQLCore.h.

◆ __states

unsigned int SQL::Connection::__states
protected

Definition at line 379 of file SQLCore.h.

◆ _filename

__PROTECTED const wchar_t* SQL::Connection::_filename

Definition at line 390 of file SQLCore.h.

◆ _line

__PROTECTED const wchar_t int SQL::Connection::_line

Definition at line 390 of file SQLCore.h.


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