- <dependency>
- <groupId>com.alibabagroupId>
- <artifactId>druidartifactId>
- <version>1.2.16version>
- dependency>
- <dependency>
- <groupId>com.alibabagroupId>
- <artifactId>fastjsonartifactId>
- <version>1.2.62version>
- dependency>
- <dependency>
- <groupId>org.apache.logging.log4jgroupId>
- <artifactId>log4j-apiartifactId>
- <version>2.15.0version>
- dependency>
- <dependency>
- <groupId>org.apache.logging.log4jgroupId>
- <artifactId>log4j-coreartifactId>
- <version>2.15.0version>
- dependency>
- # ???????
- url=jdbc:mysql://localhost:3306/db02
- username=root
- password=123456
- driverClassName=com.mysql.jdbc.Driver
-
- # ????????
- initialSize=5
- spring.datasource.min-idle=5
- maxActive=50
- maxWait=60000
-
- public static void main(String[] args) throws Exception {
- // 记载配置文件
- Properties properties = new Properties();
- properties.load(new FileInputStream("src/Druid.properties"));
- // 建立连接
- DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
- // 获取连接池对象
- Connection connection = dataSource.getConnection();
- System.out.println(connection);
-
- }