File indexing completed on 2025-08-03 08:22:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef __ODBCXX_DRIVERMANAGER_H
0023 #define __ODBCXX_DRIVERMANAGER_H
0024
0025 #include <RDBC/odbc++/setup.h>
0026
0027 #include <RDBC/odbc++/types.h>
0028
0029
0030 namespace odbc {
0031
0032 class Connection;
0033
0034
0035
0036 class ODBCXX_EXPORT Driver {
0037 private:
0038 ODBCXX_STRING description_;
0039 std::vector<ODBCXX_STRING> attributes_;
0040
0041 Driver(const Driver&);
0042 Driver& operator=(const Driver&);
0043
0044 public:
0045
0046 Driver(const ODBCXX_STRING& description,
0047 const std::vector<ODBCXX_STRING>& attributes)
0048 :description_(description), attributes_(attributes) {}
0049
0050
0051 virtual ~Driver() {}
0052
0053
0054 const ODBCXX_STRING& getDescription() const {
0055 return description_;
0056 }
0057
0058
0059 const std::vector<ODBCXX_STRING>& getAttributes() const {
0060 return attributes_;
0061 }
0062 };
0063
0064
0065 typedef CleanVector<Driver*> DriverList;
0066
0067
0068
0069 class ODBCXX_EXPORT DataSource {
0070 private:
0071 ODBCXX_STRING name_;
0072 ODBCXX_STRING description_;
0073
0074 public:
0075
0076 DataSource(const ODBCXX_STRING& name, const ODBCXX_STRING& description)
0077 :name_(name), description_(description) {}
0078
0079
0080 virtual ~DataSource() {}
0081
0082
0083 const ODBCXX_STRING& getName() const {
0084 return name_;
0085 }
0086
0087
0088 const ODBCXX_STRING& getDescription() const {
0089 return description_;
0090 }
0091 };
0092
0093
0094 typedef CleanVector<DataSource*> DataSourceList;
0095
0096
0097
0098
0099 class ODBCXX_EXPORT DriverManager {
0100 private:
0101 static SQLHENV henv_;
0102 static ErrorHandler* eh_;
0103 static int loginTimeout_;
0104
0105 static void _checkInit();
0106 static Connection* _createConnection();
0107
0108
0109 DriverManager();
0110
0111 public:
0112
0113
0114 static Connection* getConnection(const ODBCXX_STRING& dsn,
0115 const ODBCXX_STRING& user,
0116 const ODBCXX_STRING& password);
0117
0118
0119
0120
0121 static Connection* getConnection(const ODBCXX_STRING& connectString);
0122
0123
0124
0125
0126 static int getLoginTimeout();
0127
0128
0129
0130
0131
0132 static void setLoginTimeout(int seconds);
0133
0134
0135
0136 static DataSourceList* getDataSources();
0137
0138
0139
0140 static DriverList* getDrivers();
0141
0142
0143
0144
0145 static void shutdown();
0146 };
0147
0148
0149
0150 };
0151
0152
0153 #endif