reverting back the changes. causes core dump
[csql.git] / include / SqlOdbcConnection.h
blobbc0c90d25dbb1d70ba04afac41fb7ad928e10f37
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 #ifdef WINNT
29 typedef signed short int SWORD;
30 #endif
32 struct SQLFuncPtrs{
33 SQLRETURN (*SQLAllocHandlePtr)(SQLSMALLINT, SQLHANDLE, SQLHANDLE*);
34 SQLRETURN (*SQLSetEnvAttrPtr)(SQLHENV, SQLINTEGER, SQLPOINTER, SQLINTEGER);
35 SQLRETURN (*SQLDriverConnectPtr)(SQLHDBC, SQLHWND, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLUSMALLINT);
36 SQLRETURN (*SQLGetDiagRecPtr)(SQLSMALLINT, SQLHANDLE, SQLSMALLINT, SQLCHAR*, SQLINTEGER*, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*);
37 SQLRETURN (*SQLSetConnectAttrPtr)(SQLHDBC, SQLINTEGER, SQLPOINTER, SQLINTEGER);
38 SQLRETURN (*SQLSetStmtAttrPtr)(SQLHSTMT, SQLINTEGER, SQLPOINTER, SQLINTEGER);
39 SQLRETURN (*SQLFreeHandlePtr)(SQLSMALLINT, SQLHANDLE);
40 SQLRETURN (*SQLTransactPtr)(SQLHENV, SQLHDBC, SQLUSMALLINT);
42 SQLRETURN (*SQLExecDirectPtr)(SQLHSTMT, SQLCHAR*, SQLINTEGER);
43 SQLRETURN (*SQLPreparePtr)(SQLHSTMT, SQLCHAR*, SQLINTEGER);
44 SQLRETURN (*SQLNumResultColsPtr)(SQLHSTMT, SQLSMALLINT*);
45 SQLRETURN (*SQLDescribeColPtr)(SQLHSTMT, SQLUSMALLINT, SQLCHAR*, SQLSMALLINT, SQLSMALLINT*, SQLSMALLINT*, SQLULEN*,SQLSMALLINT*, SQLSMALLINT*);
46 SQLRETURN (*SQLBindColPtr)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
47 SQLRETURN (*SQLNumParamsPtr)(SQLHSTMT, SQLSMALLINT*);
48 SQLRETURN (*SQLDescribeParamPtr)(SQLHSTMT, SQLUSMALLINT, SQLSMALLINT*, SQLULEN*, SQLSMALLINT*, SQLSMALLINT*);
49 SQLRETURN (*SQLBindParameterPtr)( SQLHSTMT, SQLUSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLSMALLINT, SQLULEN, SQLSMALLINT, SQLPOINTER, SQLLEN, SQLLEN*);
50 SQLRETURN (*SQLExecutePtr)(SQLHSTMT);
51 SQLRETURN (*SQLRowCountPtr)(SQLHSTMT, SQLLEN*);
52 SQLRETURN (*SQLFetchPtr)(SQLHSTMT);
53 SQLRETURN (*SQLFetchScrollPtr)(SQLHSTMT, SQLSMALLINT, SQLLEN);
54 SQLRETURN (*SQLCloseCursorPtr)(SQLHSTMT);
55 SQLRETURN (*SQLPrimaryKeysPtr)( SQLHSTMT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT, SQLCHAR*, SQLSMALLINT);
56 SQLRETURN (*SQLGetDataPtr)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLPOINTER, SQLLEN,SQLLEN*);
57 SQLRETURN (*SQLDisconnectPtr)(SQLHDBC);
58 SQLRETURN (*SQLTablesPtr)(SQLHSTMT ,SQLCHAR *, SQLSMALLINT , SQLCHAR * , SQLSMALLINT, SQLCHAR *, SQLSMALLINT, SQLCHAR*,SQLSMALLINT);
59 SQLRETURN (*SQLProcedureColumnsPtr)(SQLHSTMT, SQLCHAR *, SQLSMALLINT, SQLCHAR *, SQLSMALLINT, SQLCHAR *, SQLSMALLINT,SQLCHAR *, SQLSMALLINT);
62 /**
63 * @class SqlOdbcConnection
66 //class SqlOdbcSym {
67 // public:
68 //};
70 class DllExport SqlOdbcConnection : public AbsSqlConnection
72 Connection dummyConn;
73 char errState[STATE_LENGTH];
74 char dsName[IDENTIFIER_LENGTH];
75 bool isConnOpen;
76 TDBInfo tdbName;
77 public:
78 SQLHENV envHdl;
79 SQLHDBC dbHdl;
80 char dsString[IDENTIFIER_LENGTH];
81 IsolationLevel prevIsoLevel;
82 SqlOdbcConnection()
84 strcpy(errState,"00000");
85 innerConn = NULL;
86 tdbName = mysql;
87 prevIsoLevel = READ_COMMITTED;
88 dsName[0]='\0';
89 isConnOpen = false;
91 ~SqlOdbcConnection(){}
93 void setDsName(char *dsname){ strcpy(dsName,dsname);}
94 char *getDsName(){return dsName;}
95 void setTrDbName(char *name);
96 TDBInfo getTrDbName(){return tdbName;}
97 static bool symbolsLoaded;
98 static struct SQLFuncPtrs ODBCFuncPtrs;
100 void setErrorState( SQLHDBC dbc);
101 DbRetVal loadSymbols();
103 //Note::forced to implement this as it is pure virtual in base class
104 Connection& getConnObject(){ return dummyConn; }
105 bool isConnectionOpen() { if (isConnOpen) return true; return false; }
107 DbRetVal connect (char *user, char * pass);
109 DbRetVal disconnect();
111 DbRetVal commit();
113 DbRetVal rollback();
115 DbRetVal beginTrans (IsolationLevel isoLevel, TransSyncMode mode);
117 friend class SqlFactory;
120 #endif