/**
* 作为所有Dao实现类的一个基类(父类)
* @author BluceYoung
* 2020-4-13
*/
public class BaseDao {
// 加载驱动的字符串
static String driverClass = "com.mysql.jdbc.Driver";
// 数据库字符串
static String url = "jdbc:mysql://localhost:3306/hrinfo?userUnicode=true&character=utf-8";
// 数据库用户名
static String user = "root";
// 密码
static String pwd = "abc123";
static {
System.out.println("读取配置文件");
Properties properties=new Properties();
try {
//创建一个读取配置文件的输入流
InputStream is=BaseDao.class.getClassLoader().getResourceAsStream("database.properties");
properties.load(is);//开始读取文件里的信息到properties对象中
driverClass=properties.getProperty("driver");
url=properties.getProperty("url");
user=properties.getProperty("name");
pwd=properties.getProperty("pwd");
} catch (IOException e) {
System.out.println
JDBC之BaseDao
最新推荐文章于 2024-03-27 20:41:24 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)