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