1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.dbcp2;
18
19 import java.sql.Connection;
20 import java.sql.Driver;
21 import java.sql.SQLException;
22 import java.util.Properties;
23
24
25
26
27
28
29 public class DriverConnectionFactory implements ConnectionFactory {
30
31 private final String connectionString;
32
33 private final Driver driver;
34
35 private final Properties properties;
36
37
38
39
40
41
42
43
44 public DriverConnectionFactory(final Driver driver, final String connectString, final Properties properties) {
45 this.driver = driver;
46 this.connectionString = connectString;
47 this.properties = properties;
48 }
49
50 @Override
51 public Connection createConnection() throws SQLException {
52 return driver.connect(connectionString, properties);
53 }
54
55
56
57
58
59 public String getConnectionString() {
60 return connectionString;
61 }
62
63
64
65
66
67 public Driver getDriver() {
68 return driver;
69 }
70
71
72
73
74
75 public Properties getProperties() {
76 return properties;
77 }
78
79 @Override
80 public String toString() {
81 return this.getClass().getName() + " [" + driver + ";" + connectionString + ";"
82 + Utils.cloneWithoutCredentials(properties) + "]";
83 }
84 }