ffead.server.doc
CibernateConnectionPool.h
1 /*
2  Copyright 2009-2012, Sumeet Chhetri
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 /*
17  * CibernateConnectionPool.h
18  *
19  * Created on: Jan 17, 2010
20  * Author: sumeet
21  */
22 
23 #ifndef CIBERNATECONNECTIONPOOL_H_
24 #define CIBERNATECONNECTIONPOOL_H_
25 #include <sqltypes.h>
26 #include <sql.h>
27 #include <sqlext.h>
28 #include "vector"
29 #include "string"
30 #include "math.h"
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include "Timer.h"
34 #include "Logger.h"
35 using namespace std;
36 
38 {
39  Logger logger;
40  Connection();
41  friend class CibernateConnectionPool;
42 public:
43  bool busy;
44  bool type;
45  SQLHDBC conn;
46  ~Connection();
47 };
48 typedef vector<Connection*> connVec;
50  Logger logger;
51  int readNumber;
52  string dbName,uname,pass;
53  SQLHENV V_OD_Env;// Handle ODBC environment
54  connVec readConnections;
55  connVec writeConnections;
56  void newConnection(bool);
57  void createPool(int,string,string,string);
58 public:
59  CibernateConnectionPool(int,string,string,string);
60  virtual ~CibernateConnectionPool();
61  //static CibernateConnectionPool* getInstance();
62  Connection* getReadConnection();
63  Connection* getWriteConnection();
64  void closeConnection(Connection*);
65  bool initialized;
66 };
67 
68 #endif /* CIBERNATECONNECTIONPOOL_H_ */