|
|
@@ -3,32 +3,38 @@ package cn.hutool.db.ds.pooled;
|
|
|
import cn.hutool.db.DbRuntimeException;
|
|
|
import cn.hutool.db.dialect.DriverUtil;
|
|
|
|
|
|
+import java.util.Properties;
|
|
|
+
|
|
|
/**
|
|
|
* 数据库配置
|
|
|
- * @author Looly
|
|
|
*
|
|
|
+ * @author Looly
|
|
|
*/
|
|
|
public class DbConfig {
|
|
|
-
|
|
|
+
|
|
|
//-------------------------------------------------------------------- Fields start
|
|
|
- private String driver; //数据库驱动
|
|
|
- private String url; //jdbc url
|
|
|
- private String user; //用户名
|
|
|
- private String pass; //密码
|
|
|
-
|
|
|
- private int initialSize; //初始连接数
|
|
|
- private int minIdle; //最小闲置连接数
|
|
|
- private int maxActive; //最大活跃连接数
|
|
|
- private long maxWait; //获取连接的超时等待
|
|
|
+ private String driver; //数据库驱动
|
|
|
+ private String url; //jdbc url
|
|
|
+ private String user; //用户名
|
|
|
+ private String pass; //密码
|
|
|
+
|
|
|
+ private int initialSize; //初始连接数
|
|
|
+ private int minIdle; //最小闲置连接数
|
|
|
+ private int maxActive; //最大活跃连接数
|
|
|
+ private long maxWait; //获取连接的超时等待
|
|
|
+
|
|
|
+ // 连接配置
|
|
|
+ private Properties connProps;
|
|
|
//-------------------------------------------------------------------- Fields end
|
|
|
-
|
|
|
+
|
|
|
//-------------------------------------------------------------------- Constructor start
|
|
|
public DbConfig() {
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 构造
|
|
|
- * @param url jdbc url
|
|
|
+ *
|
|
|
+ * @param url jdbc url
|
|
|
* @param user 用户名
|
|
|
* @param pass 密码
|
|
|
*/
|
|
|
@@ -36,10 +42,11 @@ public class DbConfig {
|
|
|
init(url, user, pass);
|
|
|
}
|
|
|
//-------------------------------------------------------------------- Constructor end
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 初始化
|
|
|
- * @param url jdbc url
|
|
|
+ *
|
|
|
+ * @param url jdbc url
|
|
|
* @param user 用户名
|
|
|
* @param pass 密码
|
|
|
*/
|
|
|
@@ -54,56 +61,85 @@ public class DbConfig {
|
|
|
throw new DbRuntimeException(e, "Get jdbc driver from [{}] error!", url);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//-------------------------------------------------------------------- Getters and Setters start
|
|
|
public String getDriver() {
|
|
|
return driver;
|
|
|
}
|
|
|
+
|
|
|
public void setDriver(String driver) {
|
|
|
this.driver = driver;
|
|
|
}
|
|
|
+
|
|
|
public String getUrl() {
|
|
|
return url;
|
|
|
}
|
|
|
+
|
|
|
public void setUrl(String url) {
|
|
|
this.url = url;
|
|
|
}
|
|
|
+
|
|
|
public String getUser() {
|
|
|
return user;
|
|
|
}
|
|
|
+
|
|
|
public void setUser(String user) {
|
|
|
this.user = user;
|
|
|
}
|
|
|
+
|
|
|
public String getPass() {
|
|
|
return pass;
|
|
|
}
|
|
|
+
|
|
|
public void setPass(String pass) {
|
|
|
this.pass = pass;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public int getInitialSize() {
|
|
|
return initialSize;
|
|
|
}
|
|
|
+
|
|
|
public void setInitialSize(int initialSize) {
|
|
|
this.initialSize = initialSize;
|
|
|
}
|
|
|
+
|
|
|
public int getMinIdle() {
|
|
|
return minIdle;
|
|
|
}
|
|
|
+
|
|
|
public void setMinIdle(int minIdle) {
|
|
|
this.minIdle = minIdle;
|
|
|
}
|
|
|
+
|
|
|
public int getMaxActive() {
|
|
|
return maxActive;
|
|
|
}
|
|
|
+
|
|
|
public void setMaxActive(int maxActive) {
|
|
|
this.maxActive = maxActive;
|
|
|
}
|
|
|
+
|
|
|
public long getMaxWait() {
|
|
|
return maxWait;
|
|
|
}
|
|
|
+
|
|
|
public void setMaxWait(long maxWait) {
|
|
|
this.maxWait = maxWait;
|
|
|
}
|
|
|
+
|
|
|
+ public Properties getConnProps() {
|
|
|
+ return connProps;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setConnProps(Properties connProps) {
|
|
|
+ this.connProps = connProps;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void addConnProps(String key, String value){
|
|
|
+ if(null == this.connProps){
|
|
|
+ this.connProps = new Properties();
|
|
|
+ }
|
|
|
+ this.connProps.setProperty(key, value);
|
|
|
+ }
|
|
|
//-------------------------------------------------------------------- Getters and Setters end
|
|
|
}
|