public class SimpleDataSource extends Object implements DataSource, Closeable
把用户名,密码,jdbcURL设置一下,这个类就能用了!!
当然,你在你的 CLASSPATH 下要放置相应的数据库驱动 jar 包
| Modifier and Type | Field and Description |
|---|---|
protected String |
driverClassName |
protected String |
jdbcUrl |
protected String |
password |
protected String |
username |
| Constructor and Description |
|---|
SimpleDataSource() |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static DataSource |
createDataSource(Properties props) |
Connection |
getConnection()
这是唯一会被NutDao调用的方法
|
Connection |
getConnection(String username,
String password) |
int |
getLoginTimeout() |
PrintWriter |
getLogWriter() |
Logger |
getParentLogger() |
boolean |
isWrapperFor(Class<?> iface) |
void |
setDriverClassName(String driverClassName) |
void |
setJdbcUrl(String jdbcUrl) |
void |
setLoginTimeout(int seconds) |
void |
setLogWriter(PrintWriter out) |
void |
setPassword(String password) |
void |
setUrl(String url) |
void |
setUsername(String username) |
<T> T |
unwrap(Class<T> iface) |
protected String username
protected String password
protected String driverClassName
protected String jdbcUrl
public Connection getConnection() throws SQLException
getConnection in interface DataSourceSQLExceptionpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic void setDriverClassName(String driverClassName) throws ClassNotFoundException
ClassNotFoundExceptionpublic void setUsername(String username)
public void setPassword(String password)
public void setJdbcUrl(String jdbcUrl)
public void setUrl(String url)
public PrintWriter getLogWriter() throws SQLException
getLogWriter in interface CommonDataSourceSQLExceptionpublic void setLogWriter(PrintWriter out) throws SQLException
setLogWriter in interface CommonDataSourceSQLExceptionpublic void setLoginTimeout(int seconds)
throws SQLException
setLoginTimeout in interface CommonDataSourceSQLExceptionpublic int getLoginTimeout()
throws SQLException
getLoginTimeout in interface CommonDataSourceSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap in interface WrapperSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor in interface WrapperSQLExceptionpublic Connection getConnection(String username, String password) throws SQLException
getConnection in interface DataSourceSQLExceptionpublic Logger getParentLogger()
getParentLogger in interface CommonDataSourcepublic static DataSource createDataSource(Properties props)
Copyright © 2017. All rights reserved.