public class SimpleDataSource extends Object implements DataSource
把用户名,密码,jdbcURL设置一下,这个类就能用了!!
当然,你在你的 CLASSPATH 下要放置相应的数据库驱动 jar 包
限定符和类型 | 字段和说明 |
---|---|
protected String |
driverClassName |
protected String |
jdbcUrl |
protected String |
password |
protected String |
username |
构造器和说明 |
---|
SimpleDataSource() |
限定符和类型 | 方法和说明 |
---|---|
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 |
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
在接口中 DataSource
SQLException
public void close()
public void setDriverClassName(String driverClassName) throws ClassNotFoundException
public void setUsername(String username)
public void setPassword(String password)
public void setJdbcUrl(String jdbcUrl)
public PrintWriter getLogWriter() throws SQLException
getLogWriter
在接口中 CommonDataSource
SQLException
public void setLogWriter(PrintWriter out) throws SQLException
setLogWriter
在接口中 CommonDataSource
SQLException
public void setLoginTimeout(int seconds) throws SQLException
setLoginTimeout
在接口中 CommonDataSource
SQLException
public int getLoginTimeout() throws SQLException
getLoginTimeout
在接口中 CommonDataSource
SQLException
public <T> T unwrap(Class<T> iface) throws SQLException
unwrap
在接口中 Wrapper
SQLException
public boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor
在接口中 Wrapper
SQLException
public Connection getConnection(String username, String password) throws SQLException
getConnection
在接口中 DataSource
SQLException
public Logger getParentLogger()
getParentLogger
在接口中 CommonDataSource
public static DataSource createDataSource(Properties props)
Copyright © 2017. All rights reserved.