public class SimpleDataSource extends AbstractDataSource
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DB_CONFIG_PATH
默认的数据库连接配置文件路径
|
Constructor and Description |
---|
SimpleDataSource()
构造
|
SimpleDataSource(Setting setting,
String group)
构造
|
SimpleDataSource(String group)
构造
|
SimpleDataSource(String url,
String user,
String pass)
构造
|
SimpleDataSource(String url,
String user,
String pass,
String driver)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
addConnProps(String key,
String value) |
void |
close() |
Connection |
getConnection() |
Connection |
getConnection(String username,
String password) |
Properties |
getConnProps() |
static SimpleDataSource |
getDataSource()
获得一个数据源,无分组
|
static SimpleDataSource |
getDataSource(String group)
获得一个数据源
|
String |
getDriver() |
String |
getPass() |
String |
getUrl() |
String |
getUser() |
void |
init(String url,
String user,
String pass)
初始化
|
void |
init(String url,
String user,
String pass,
String driver)
初始化
|
void |
setConnProps(Properties connProps) |
void |
setDriver(String driver) |
void |
setPass(String pass) |
void |
setUrl(String url) |
void |
setUser(String user) |
getLoginTimeout, getLogWriter, getParentLogger, isWrapperFor, setLoginTimeout, setLogWriter, unwrap
public static final String DEFAULT_DB_CONFIG_PATH
public SimpleDataSource()
public SimpleDataSource(String group)
group
- 数据库配置文件中的分组public SimpleDataSource(Setting setting, String group)
setting
- 数据库配置group
- 数据库配置文件中的分组public SimpleDataSource(String url, String user, String pass)
url
- jdbc urluser
- 用户名pass
- 密码public static SimpleDataSource getDataSource(String group)
group
- 数据源分组public static SimpleDataSource getDataSource()
public void init(String url, String user, String pass)
url
- jdbc urluser
- 用户名pass
- 密码public void init(String url, String user, String pass, String driver)
url
- jdbc urluser
- 用户名pass
- 密码driver
- JDBC驱动类,传入空则自动识别驱动类public String getDriver()
public void setDriver(String driver)
public String getUrl()
public void setUrl(String url)
public String getUser()
public void setUser(String user)
public String getPass()
public void setPass(String pass)
public Properties getConnProps()
public void setConnProps(Properties connProps)
public Connection getConnection() throws SQLException
SQLException
public Connection getConnection(String username, String password) throws SQLException
SQLException
public void close()
Copyright © 2024. All rights reserved.