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 DataSource
SQLException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public void setDriverClassName(String driverClassName) throws ClassNotFoundException
ClassNotFoundException
public 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 CommonDataSource
SQLException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
in interface CommonDataSource
SQLException
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
in interface CommonDataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
in interface CommonDataSource
SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
in interface Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
in interface Wrapper
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
in interface DataSource
SQLException
public Logger getParentLogger()
getParentLogger
in interface CommonDataSource
public static DataSource createDataSource(Properties props)
Copyright © 2017. All rights reserved.