00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __ODBCXX_DRIVERMANAGER_H
00023 #define __ODBCXX_DRIVERMANAGER_H
00024
00025 #include <odbc++/setup.h>
00026
00027 #include <odbc++/types.h>
00028
00030 namespace odbc {
00031
00032 class Connection;
00033 class ErrorHandler;
00034
00037 class ODBCXX_EXPORT Driver {
00038 private:
00039 ODBCXX_STRING description_;
00040 std::vector<ODBCXX_STRING> attributes_;
00041
00042 Driver(const Driver&);
00043 Driver& operator=(const Driver&);
00044
00045 public:
00047 Driver(const ODBCXX_STRING& description,
00048 const std::vector<ODBCXX_STRING>& attributes)
00049 :description_(description), attributes_(attributes) {}
00050
00052 virtual ~Driver() {}
00053
00055 const ODBCXX_STRING& getDescription() const {
00056 return description_;
00057 }
00058
00060 const std::vector<ODBCXX_STRING>& getAttributes() const {
00061 return attributes_;
00062 }
00063 };
00064
00066 typedef CleanVector<Driver*> DriverList;
00067
00068
00070 class ODBCXX_EXPORT DataSource {
00071 private:
00072 ODBCXX_STRING name_;
00073 ODBCXX_STRING description_;
00074
00075 public:
00077 DataSource(const ODBCXX_STRING& name, const ODBCXX_STRING& description)
00078 :name_(name), description_(description) {}
00079
00081 virtual ~DataSource() {}
00082
00084 const ODBCXX_STRING& getName() const {
00085 return name_;
00086 }
00087
00089 const ODBCXX_STRING& getDescription() const {
00090 return description_;
00091 }
00092 };
00093
00095 typedef CleanVector<DataSource*> DataSourceList;
00096
00097
00100 class ODBCXX_EXPORT DriverManager {
00101 private:
00102 static SQLHENV henv_;
00103 static ErrorHandler* eh_;
00104 static int loginTimeout_;
00105
00106 static void _checkInit();
00107 static Connection* _createConnection();
00108
00109
00110 DriverManager();
00111
00112 public:
00113
00115 static Connection* getConnection(const ODBCXX_STRING& dsn,
00116 const ODBCXX_STRING& user,
00117 const ODBCXX_STRING& password);
00118
00122 static Connection* getConnection(const ODBCXX_STRING& connectString);
00123
00127 static int getLoginTimeout();
00128
00133 static void setLoginTimeout(int seconds);
00134
00137 static DataSourceList* getDataSources();
00138
00141 static DriverList* getDrivers();
00142
00146 static void shutdown();
00147 };
00148
00149
00150
00151 }
00152
00153
00154 #endif // __ODBCXX_DRIVERMANAGER_H