使用JDBC连接数据库例子中的方法疑惑?
ackage onlyfun.caterpillar;
import java.io.FileInputStream;
import
java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import
java.sql.SQLException;
import java.util.Properties;
public class SimpleDBSource implements DBSource {
private Properties props;
private String url;
private String user;
private String passwd;
public SimpleDBSource() throws
IOException,
ClassNotFoundException {
this("jdbc.properties");
}
public SimpleDBSource(String configFile) throws IOException,
Class
NotFoundException {
props = new Properties();
props.load(new FileInputStream(configFile));
url = props.getProperty("onlyfun.caterpillar.url");
user = props.getProperty("onlyfun.caterpillar.user");
passwd = props.getProperty("onlyfun.caterpillar.password");
Class.forName(
props.getProperty("onlyfun.caterpillar.driver"));
}
public Connection getConnection() throws
SQLException {
return DriverManager.getConnection(url, user, passwd);
}
public void closeConnection(Connection conn) throws SQLException {
conn.close();
}
}
以上是一个例子中的代码,相信大家也看得懂,我就是不明白,类中的无参构造方法中的this("jdbc.properties");,是什么意思的,还有这种写法???还有它与下面的有参构造方法是什么联系的?求大家详解
------解决方案--------------------