使用Druid连接数据库
时间:2021-07-01 10:21:17
帮助过:37人阅读
static DataSource source;
static {
try {
Properties properties =
new Properties();
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("Druid.properties"
);
properties.load(is);
source =
DruidDataSourceFactory.createDataSource(properties);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection()
throws SQLException {
Connection connection =
source.getConnection();
return connection;
}
使用Druid连接数据库
标签:mysq 数据库连接 数据 use static 导包 throws actor connect