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
00036 class ODBCXX_EXPORT Driver {
00037 private:
00038 ODBCXX_STRING description_;
00039 std::vector<ODBCXX_STRING> attributes_;
00040
00041 Driver(const Driver&);
00042 Driver& operator=(const Driver&);
00043
00044 public:
00046 Driver(const ODBCXX_STRING& description,
00047 const std::vector<ODBCXX_STRING>& attributes)
00048 :description_(description), attributes_(attributes) {}
00049
00051 virtual ~Driver() {}
00052
00054 const ODBCXX_STRING& getDescription() const {
00055 return description_;
00056 }
00057
00059 const std::vector<ODBCXX_STRING>& getAttributes() const {
00060 return attributes_;
00061 }
00062 };
00063
00065 typedef CleanVector<Driver*> DriverList;
00066
00067
00069 class ODBCXX_EXPORT DataSource {
00070 private:
00071 ODBCXX_STRING name_;
00072 ODBCXX_STRING description_;
00073
00074 public:
00076 DataSource(const ODBCXX_STRING& name, const ODBCXX_STRING& description)
00077 :name_(name), description_(description) {}
00078
00080 virtual ~DataSource() {}
00081
00083 const ODBCXX_STRING& getName() const {
00084 return name_;
00085 }
00086
00088 const ODBCXX_STRING& getDescription() const {
00089 return description_;
00090 }
00091 };
00092
00094 typedef CleanVector<DataSource*> DataSourceList;
00095
00096
00099 class ODBCXX_EXPORT DriverManager {
00100 private:
00101 static SQLHENV henv_;
00102 static ErrorHandler* eh_;
00103 static int loginTimeout_;
00104
00105 static void _checkInit();
00106 static Connection* _createConnection();
00107
00108
00109 DriverManager();
00110
00111 public:
00112
00114 static Connection* getConnection(const ODBCXX_STRING& dsn,
00115 const ODBCXX_STRING& user,
00116 const ODBCXX_STRING& password);
00117
00121 static Connection* getConnection(const ODBCXX_STRING& connectString);
00122
00126 static int getLoginTimeout();
00127
00132 static void setLoginTimeout(int seconds);
00133
00136 static DataSourceList* getDataSources();
00137
00140 static DriverList* getDrivers();
00141
00145 static void shutdown();
00146 };
00147
00148
00149
00150 };
00151
00152
00153 #endif // __ODBCXX_DRIVERMANAGER_H