|
1 | 1 | part of dart_gdbc; |
2 | 2 |
|
| 3 | +/// The basic service for managing a set of GDBC drivers. |
| 4 | +/// Two things are supported in DriverManager: |
| 5 | +/// * You can register a driver with the [DriverManager.registerDriver(driver)]. |
| 6 | +/// * You can request a connection using the [DriverManager.getConnection] method. |
| 7 | +/// --- |
| 8 | +/// 驅動程序管理器的基本服務。 |
| 9 | +/// DriverManager支持兩件事: |
| 10 | +/// * 您可以使用[DriverManager.registerDriver(driver)]註冊驅動程序。 |
| 11 | +/// * 您可以使用[DriverManager.getConnection]方法請求連接。 |
| 12 | +///--- |
| 13 | +/// 驱动程序管理器的基本服务。 |
| 14 | +/// DriverManager支持两件事: |
| 15 | +/// * 您可以使用[DriverManager.registerDriver(driver)]注册驱动程序。 |
| 16 | +/// * 您可以使用[DriverManager.getConnection]方法请求连接。 |
3 | 17 | class DriverManager { |
4 | 18 | static const String usrKey = 'username'; |
5 | 19 | static const String pwdKey = 'password'; |
6 | 20 |
|
7 | 21 | static final Map<String, Driver> _drivers = {}; |
8 | 22 |
|
| 23 | + /// Register a driver with the driver manager. |
| 24 | + ///--- |
| 25 | + /// 使用驱动程序管理器注册驱动程序。 |
| 26 | + ///--- |
| 27 | + /// 使用驅動程序管理器註冊驅動程序。 |
9 | 28 | static void registerDriver(Driver driver, [String? driverId]) { |
10 | 29 | _drivers[driverId ?? driver.runtimeType.toString()] = driver; |
11 | 30 | } |
12 | 31 |
|
| 32 | + /// Get a connection from the first driver that recognizes the given URL. |
| 33 | + /// username and password are optional, if you don't provide them in the url, you can provide them in the properties. |
| 34 | + /// --- |
| 35 | + /// 通過url獲取第一個格式相符的驅動程序的連接。 |
| 36 | + /// username和password是可選的,可以通過 properties 傳入,可以通過 url 傳入。 |
| 37 | + /// 不過通過 url 傳入的方式是不可靠的,依托具體的數據庫驅動包。 |
| 38 | + /// --- |
| 39 | + /// 通过url获取第一个格式相符的驱动程序的连接。 |
| 40 | + /// username和password是可选的,可以通过 properties 传入,可以通过 url 传入, |
| 41 | + /// 不过通过 url 传入的方式是不可靠的,依托具体的数据库驱动包。 |
13 | 42 | static Future<Connection> getConnection( |
14 | 43 | String url, { |
15 | 44 | Map<String, dynamic>? properties, |
|
0 commit comments