allocator fixes
[csql.git] / include / SqlOdbcConnection.h
blobd505f84f2bb15031973109b726455a10d777108a
1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef SQLODBCCONNECTION_H
21 #define SQLODBCCONNECTION_H
22 #include<CSql.h>
23 #include<AbsSqlConnection.h>
24 #include<SqlFactory.h>
25 #include <sql.h>
26 #include <sqlext.h>
28 struct SQLFuncPtrs{
29 SQLRETURN (*SQLAllocHandlePtr)(SQLSMALLINT, SQLHANDLE, SQLHANDLE*);
30 SQLRETURN (*SQLSetEnvAttrPtr)(SQLHENV, SQLINTEGER, SQLPOINTER, SQLINTEGER);
31 SQLRETURN (*SQLDriverConnectPtr)(SQLHDBC, SQLHWND, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLUSMALLINT);
32 SQLRETURN (*SQLGetDiagRecPtr)(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
33 SQLRETURN (*SQLSetConnectAttrPtr)(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER);
34 SQLRETURN (*SQLFreeHandlePtr)(SQLSMALLINT, SQLHANDLE);
35 SQLRETURN (*SQLTransactPtr)(SQLHENV, SQLHDBC, SQLUSMALLINT);
37 SQLRETURN (*SQLExecDirectPtr)(SQLHSTMT, SQLCHAR*, SQLINTEGER);
38 SQLRETURN (*SQLPreparePtr)(SQLHSTMT, SQLCHAR*, SQLINTEGER);
39 SQLRETURN (*SQLNumResultColsPtr)(SQLHSTMT, SQLSMALLINT*);
40 SQLRETURN (*SQLDescribeColPtr)(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLULEN*,SQLSMALLINT*, SQLSMALLINT*);
41 SQLRETURN (*SQLBindColPtr)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
42 SQLRETURN (*SQLNumParamsPtr)(SQLHSTMT, SQLSMALLINT*);
43 SQLRETURN (*SQLDescribeParamPtr)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
44 SQLRETURN (*SQLBindParameterPtr)( SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
45 SQLRETURN (*SQLExecutePtr)(SQLHSTMT);
46 SQLRETURN (*SQLRowCountPtr)(SQLHSTMT, SQLLEN*);
47 SQLRETURN (*SQLFetchPtr)(SQLHSTMT);
48 SQLRETURN (*SQLCloseCursorPtr)(SQLHSTMT);
49 SQLRETURN (*SQLPrimaryKeysPtr)( SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
50 SQLRETURN (*SQLGetDataPtr)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER, SQLLEN,SQLLEN*);
51 SQLRETURN (*SQLDisconnectPtr)(SQLHDBC);
52 SQLRETURN (*SQLTablesPtr)(SQLHSTMT ,SQLCHAR *, SQLSMALLINT , SQLCHAR * , SQLSMALLINT, SQLCHAR *, SQLSMALLINT, SQLCHAR*,SQLSMALLINT);
53 SQLRETURN (*SQLProcedureColumnsPtr)(SQLHSTMT, SQLCHAR *, SQLSMALLINT, SQLCHAR *, SQLSMALLINT, SQLCHAR *, SQLSMALLINT,SQLCHAR *, SQLSMALLINT);
57 /**
58 * @class SqlOdbcConnection
61 //class SqlOdbcSym {
62 // public:
63 //};
65 class SqlOdbcConnection : public AbsSqlConnection
67 Connection dummyConn;
68 TDBInfo tdbName;
69 char errState[STATE_LENGTH];
70 char dsnAdapter[IDENTIFIER_LENGTH];
71 bool isConnOpen;
72 public:
73 SQLHENV envHdl;
74 SQLHDBC dbHdl;
75 char dsn[IDENTIFIER_LENGTH];
76 IsolationLevel prevIsoLevel;
77 SqlOdbcConnection()
78 { strcpy(errState,"00000"); innerConn = NULL; tdbName = mysql; prevIsoLevel = READ_COMMITTED; dsnAdapter[0]='\0'; isConnOpen = false; }
79 ~SqlOdbcConnection(){}
81 void setDsn(char *dsn){ strcpy(dsnAdapter,dsn);}
82 char *getDsn(){return dsnAdapter;}
83 void setTrDbName(char *name);
84 TDBInfo getTrDbName(){return tdbName;}
85 static bool symbolsLoaded;
86 static struct SQLFuncPtrs ODBCFuncPtrs;
88 void setErrorState( SQLHDBC dbc);
89 DbRetVal loadSymbols();
91 //Note::forced to implement this as it is pure virtual in base class
92 Connection& getConnObject(){ return dummyConn; }
93 bool isConnectionOpen() { if (isConnOpen) return true; return false; }
95 DbRetVal connect (char *user, char * pass);
97 DbRetVal disconnect();
99 DbRetVal commit();
101 DbRetVal rollback();
103 DbRetVal beginTrans (IsolationLevel isoLevel, TransSyncMode mode);
105 friend class SqlFactory;
108 #endif